Commit 28a0de6a8c590504e1c1e616f3609d532dffc7a4
Exists in
master
and in
1 other branch
Merge branch 'develop' into 'master'
Develop See merge request !58
Showing
5 changed files
Show diff stats
package.json
| 1 | { | 1 | { |
| 2 | "name": "foca-crear-nota-pedido", | 2 | "name": "foca-crear-nota-pedido", |
| 3 | "version": "0.0.1", | 3 | "version": "0.0.1", |
| 4 | "description": "Listado y ABM nota de pedidos", | 4 | "description": "Listado y ABM nota de pedidos", |
| 5 | "main": "index.js", | 5 | "main": "index.js", |
| 6 | "scripts": { | 6 | "scripts": { |
| 7 | "test": "test.html", | 7 | "test": "test.html", |
| 8 | "compile": "gulp uglify", | 8 | "compile": "gulp uglify", |
| 9 | "gulp-pre-commit": "gulp pre-commit", | 9 | "gulp-pre-commit": "gulp pre-commit", |
| 10 | "postinstall": "npm run compile && gulp clean-post-install", | 10 | "postinstall": "npm run compile && gulp clean-post-install", |
| 11 | "install-dev": "npm install -D jasmine-core pre-commit angular angular-ladda ladda@1.0.6 angular-route bootstrap ui-bootstrap4 font-awesome gulp gulp-angular-templatecache gulp-connect gulp-clean gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-sequence gulp-uglify-es gulp-uglify jquery jshint pump git+http://git.focasoftware.com/npm/foca-directivas.git git+http://git.focasoftware.com/npm/foca-modal-vendedores.git git+http://git.focasoftware.com/npm/foca-modal-proveedor.git git+http://git.focasoftware.com/npm/foca-modal-busqueda-productos.git git+http://git.focasoftware.com/npm/foca-busqueda-cliente.git git+http://git.focasoftware.com/npm/foca-modal-precio-condiciones.git git+http://git.focasoftware.com/npm/foca-modal-flete.git git+http://git.focasoftware.com/npm/foca-modal.git git+http://git.focasoftware.com/npm/foca-modal-domicilio.git git+http://git.focasoftware.com/npm/foca-seguimiento.git git+http://git.focasoftware.com/npm/foca-modal-moneda.git git+http://git.focasoftware.com/npm/foca-modal-cotizacion.git" | 11 | "install-dev": "npm install -D jasmine-core pre-commit angular angular-ladda ladda@1.0.6 angular-route bootstrap ui-bootstrap4 font-awesome gulp gulp-angular-templatecache gulp-connect gulp-clean gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-sequence gulp-uglify-es gulp-uglify jquery jshint pump git+http://git.focasoftware.com/npm/foca-directivas.git git+http://git.focasoftware.com/npm/foca-modal-vendedores.git git+http://git.focasoftware.com/npm/foca-modal-proveedor.git git+http://git.focasoftware.com/npm/foca-modal-busqueda-productos.git git+http://git.focasoftware.com/npm/foca-busqueda-cliente.git git+http://git.focasoftware.com/npm/foca-modal-precio-condiciones.git git+http://git.focasoftware.com/npm/foca-modal-flete.git git+http://git.focasoftware.com/npm/foca-modal.git git+http://git.focasoftware.com/npm/foca-modal-domicilio.git git+http://git.focasoftware.com/npm/foca-seguimiento.git git+http://git.focasoftware.com/npm/foca-modal-moneda.git git+http://git.focasoftware.com/npm/foca-modal-cotizacion.git" |
| 12 | }, | 12 | }, |
| 13 | "pre-commit": [ | 13 | "pre-commit": [ |
| 14 | "gulp-pre-commit" | 14 | "gulp-pre-commit" |
| 15 | ], | 15 | ], |
| 16 | "repository": { | 16 | "repository": { |
| 17 | "type": "git", | 17 | "type": "git", |
| 18 | "url": "https://debo.suite.repo/modulos-npm/foca-crear-nota-pedido.git" | 18 | "url": "https://debo.suite.repo/modulos-npm/foca-crear-nota-pedido.git" |
| 19 | }, | 19 | }, |
| 20 | "author": "Foca Software", | 20 | "author": "Foca Software", |
| 21 | "license": "ISC", | 21 | "license": "ISC", |
| 22 | "peerDependencies": { | 22 | "peerDependencies": { |
| 23 | "foca-botonera-facturador": "git+http://git.focasoftware.com/npm/foca-botonera-facturador.git", | 23 | "foca-botonera-facturador": "git+http://git.focasoftware.com/npm/foca-botonera-facturador.git", |
| 24 | "foca-busqueda-cliente": "git+http://git.focasoftware.com/npm/foca-busqueda-cliente.git", | 24 | "foca-busqueda-cliente": "git+http://git.focasoftware.com/npm/foca-busqueda-cliente.git", |
| 25 | "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git", | 25 | "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git", |
| 26 | "foca-modal": "git+http://git.focasoftware.com/npm/foca-modal.git", | 26 | "foca-modal": "git+http://git.focasoftware.com/npm/foca-modal.git", |
| 27 | "foca-modal-busqueda-productos": "git+http://git.focasoftware.com/npm/foca-modal-busqueda-productos.git", | 27 | "foca-modal-busqueda-productos": "git+http://git.focasoftware.com/npm/foca-modal-busqueda-productos.git", |
| 28 | "foca-modal-cotizacion": "git+http://git.focasoftware.com/npm/foca-modal-cotizacion.git", | 28 | "foca-modal-cotizacion": "git+http://git.focasoftware.com/npm/foca-modal-cotizacion.git", |
| 29 | "foca-modal-domicilio": "git+http://git.focasoftware.com/npm/foca-modal-domicilio.git", | 29 | "foca-modal-domicilio": "git+http://git.focasoftware.com/npm/foca-modal-domicilio.git", |
| 30 | "foca-modal-flete": "git+http://git.focasoftware.com/npm/foca-modal-flete.git", | 30 | "foca-modal-flete": "git+http://git.focasoftware.com/npm/foca-modal-flete.git", |
| 31 | "foca-modal-moneda": "git+http://git.focasoftware.com/npm/foca-modal-moneda.git", | ||
| 32 | "foca-modal-precio-condiciones": "git+http://git.focasoftware.com/npm/foca-modal-precio-condiciones.git", | 31 | "foca-modal-precio-condiciones": "git+http://git.focasoftware.com/npm/foca-modal-precio-condiciones.git", |
| 33 | "foca-modal-proveedor": "git+http://git.focasoftware.com/npm/foca-modal-proveedor.git", | ||
| 34 | "foca-modal-vendedores": "git+http://git.focasoftware.com/npm/foca-modal-vendedores.git", | ||
| 35 | "foca-seguimiento": "git+http://git.focasoftware.com/npm/foca-seguimiento.git" | 32 | "foca-seguimiento": "git+http://git.focasoftware.com/npm/foca-seguimiento.git" |
| 36 | }, | 33 | }, |
| 37 | "devDependencies": { | 34 | "devDependencies": { |
| 38 | "angular": "^1.7.5", | 35 | "angular": "^1.7.5", |
| 39 | "angular-ladda": "^0.4.3", | 36 | "angular-ladda": "^0.4.3", |
| 40 | "angular-mocks": "^1.7.7", | 37 | "angular-mocks": "^1.7.7", |
| 41 | "angular-route": "^1.7.5", | 38 | "angular-route": "^1.7.5", |
| 42 | "bootstrap": "^4.1.3", | 39 | "bootstrap": "^4.1.3", |
| 43 | "foca-busqueda-cliente": "git+http://git.focasoftware.com/npm/foca-busqueda-cliente.git", | 40 | "foca-busqueda-cliente": "git+http://git.focasoftware.com/npm/foca-busqueda-cliente.git", |
| 44 | "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git", | 41 | "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git", |
| 45 | "foca-modal": "git+http://git.focasoftware.com/npm/foca-modal.git", | 42 | "foca-modal": "git+http://git.focasoftware.com/npm/foca-modal.git", |
| 46 | "foca-modal-busqueda-productos": "git+http://git.focasoftware.com/npm/foca-modal-busqueda-productos.git", | 43 | "foca-modal-busqueda-productos": "git+http://git.focasoftware.com/npm/foca-modal-busqueda-productos.git", |
| 47 | "foca-modal-cotizacion": "git+http://git.focasoftware.com/npm/foca-modal-cotizacion.git", | 44 | "foca-modal-cotizacion": "git+http://git.focasoftware.com/npm/foca-modal-cotizacion.git", |
| 48 | "foca-modal-domicilio": "git+http://git.focasoftware.com/npm/foca-modal-domicilio.git", | 45 | "foca-modal-domicilio": "git+http://git.focasoftware.com/npm/foca-modal-domicilio.git", |
| 49 | "foca-modal-flete": "git+http://git.focasoftware.com/npm/foca-modal-flete.git", | 46 | "foca-modal-flete": "git+http://git.focasoftware.com/npm/foca-modal-flete.git", |
| 50 | "foca-modal-moneda": "git+http://git.focasoftware.com/npm/foca-modal-moneda.git", | ||
| 51 | "foca-modal-precio-condiciones": "git+http://git.focasoftware.com/npm/foca-modal-precio-condiciones.git", | 47 | "foca-modal-precio-condiciones": "git+http://git.focasoftware.com/npm/foca-modal-precio-condiciones.git", |
| 52 | "foca-modal-proveedor": "git+http://git.focasoftware.com/npm/foca-modal-proveedor.git", | ||
| 53 | "foca-modal-vendedores": "git+http://git.focasoftware.com/npm/foca-modal-vendedores.git", | ||
| 54 | "foca-seguimiento": "git+http://git.focasoftware.com/npm/foca-seguimiento.git", | 48 | "foca-seguimiento": "git+http://git.focasoftware.com/npm/foca-seguimiento.git", |
| 55 | "font-awesome": "^4.7.0", | 49 | "font-awesome": "^4.7.0", |
| 56 | "gulp": "^3.9.1", | 50 | "gulp": "^3.9.1", |
| 57 | "gulp-angular-templatecache": "^2.2.5", | 51 | "gulp-angular-templatecache": "^2.2.5", |
| 58 | "gulp-clean": "^0.4.0", | 52 | "gulp-clean": "^0.4.0", |
| 59 | "gulp-concat": "^2.6.1", | 53 | "gulp-concat": "^2.6.1", |
| 60 | "gulp-connect": "^5.6.1", | 54 | "gulp-connect": "^5.6.1", |
| 61 | "gulp-htmlmin": "^5.0.1", | 55 | "gulp-htmlmin": "^5.0.1", |
| 62 | "gulp-jshint": "^2.1.0", | 56 | "gulp-jshint": "^2.1.0", |
| 63 | "gulp-rename": "^1.4.0", | 57 | "gulp-rename": "^1.4.0", |
| 64 | "gulp-replace": "^1.0.0", | 58 | "gulp-replace": "^1.0.0", |
| 65 | "gulp-sequence": "^1.0.0", | 59 | "gulp-sequence": "^1.0.0", |
| 66 | "gulp-uglify": "^3.0.1", | 60 | "gulp-uglify": "^3.0.1", |
| 67 | "gulp-uglify-es": "^1.0.4", | 61 | "gulp-uglify-es": "^1.0.4", |
| 68 | "jasmine-core": "^3.3.0", | 62 | "jasmine-core": "^3.3.0", |
| 69 | "jquery": "^3.3.1", | 63 | "jquery": "^3.3.1", |
| 70 | "jshint": "^2.9.6", | 64 | "jshint": "^2.9.6", |
| 71 | "ladda": "1.0.6", | 65 | "ladda": "1.0.6", |
| 72 | "ngstorage": "^0.3.11", | 66 | "ngstorage": "^0.3.11", |
| 73 | "pre-commit": "^1.2.2", | 67 | "pre-commit": "^1.2.2", |
| 74 | "pump": "^3.0.0", | 68 | "pump": "^3.0.0", |
| 75 | "ui-bootstrap4": "^3.0.5" | 69 | "ui-bootstrap4": "^3.0.5" |
| 76 | } | 70 | } |
| 77 | } | 71 | } |
| 78 | 72 |
spec/controllerSpec.js
| 1 | describe('Controladores módulo crear nota de pedido', function() { | 1 | describe('Controladores módulo crear nota de pedido', function() { |
| 2 | 2 | ||
| 3 | var $controler; | 3 | var $controler; |
| 4 | 4 | ||
| 5 | beforeEach(function() { | 5 | beforeEach(function() { |
| 6 | module('focaCrearNotaPedido'); | 6 | module('focaCrearNotaPedido'); |
| 7 | inject(function(_$controller_) { | 7 | inject(function(_$controller_) { |
| 8 | $controler = _$controller_; | 8 | $controler = _$controller_; |
| 9 | }); | 9 | }); |
| 10 | }); | 10 | }); |
| 11 | 11 | ||
| 12 | describe('Controlador notaPedidoCtrl', function() { | 12 | describe('Controlador notaPedidoCtrl', function() { |
| 13 | 13 | ||
| 14 | var filter = function() { | 14 | var filter = function() { |
| 15 | return function() { }; | 15 | return function() { }; |
| 16 | }; | 16 | }; |
| 17 | var timeout; | 17 | var timeout; |
| 18 | 18 | ||
| 19 | beforeEach(function() { | 19 | beforeEach(function() { |
| 20 | 20 | ||
| 21 | inject(function($timeout) { | 21 | inject(function($timeout) { |
| 22 | timeout = $timeout; | 22 | timeout = $timeout; |
| 23 | }); | 23 | }); |
| 24 | }); | 24 | }); |
| 25 | 25 | ||
| 26 | it('La función seleccionarNotaPedido levanta modal', function() { | 26 | it('La función seleccionarNotaPedido levanta modal', function() { |
| 27 | //arrange | 27 | //arrange |
| 28 | var scope = { | 28 | var scope = { |
| 29 | $watch: function() { }, | 29 | $watch: function() { }, |
| 30 | $broadcast: function() { } | 30 | $broadcast: function() { } |
| 31 | }; | 31 | }; |
| 32 | var uibModal = { | 32 | var uibModal = { |
| 33 | open: function() { } | 33 | open: function() { } |
| 34 | }; | 34 | }; |
| 35 | 35 | ||
| 36 | $controler('notaPedidoCtrl', { | 36 | $controler('notaPedidoCtrl', { |
| 37 | $scope: scope, | 37 | $scope: scope, |
| 38 | $uibModal: uibModal, | 38 | $uibModal: uibModal, |
| 39 | $location: {}, | 39 | $location: {}, |
| 40 | $filter: filter, | 40 | $filter: filter, |
| 41 | $timeout: timeout, | 41 | $timeout: timeout, |
| 42 | crearNotaPedidoService: { | 42 | crearNotaPedidoService: { |
| 43 | getNumeroNotaPedido: function() { | 43 | getNumeroNotaPedido: function() { |
| 44 | return { | 44 | return { |
| 45 | then: function() { } | 45 | then: function() { } |
| 46 | }; | 46 | }; |
| 47 | }, | 47 | }, |
| 48 | getBotonera: function() { }, | 48 | getBotonera: function() { }, |
| 49 | getCotizacionByIdMoneda: function() { | 49 | getCotizacionByIdMoneda: function() { |
| 50 | return { | 50 | return { |
| 51 | then: function() { } | 51 | then: function() { } |
| 52 | }; | 52 | }; |
| 53 | } | 53 | } |
| 54 | }, | 54 | }, |
| 55 | focaBotoneraLateralService: {}, | 55 | focaBotoneraLateralService: {}, |
| 56 | focaModalService: {}, | 56 | focaModalService: {}, |
| 57 | notaPedidoBusinessService: {}, | 57 | notaPedidoBusinessService: {}, |
| 58 | $rootScope: { | 58 | $rootScope: { |
| 59 | $on: function() { } | 59 | $on: function() { } |
| 60 | }, | 60 | }, |
| 61 | focaSeguimientoService: {}, | 61 | focaSeguimientoService: {}, |
| 62 | APP: {}, | 62 | APP: {}, |
| 63 | focaLoginService: {}, | 63 | focaLoginService: {}, |
| 64 | $localStorage: {} | 64 | $localStorage: {} |
| 65 | }); | 65 | }); |
| 66 | var respuesta = { result: { then: function() { } } }; | 66 | var respuesta = { result: { then: function() { } } }; |
| 67 | 67 | ||
| 68 | //act | 68 | //act |
| 69 | spyOn(uibModal, 'open').and.returnValue(respuesta); | 69 | spyOn(uibModal, 'open').and.returnValue(respuesta); |
| 70 | scope.seleccionarNotaPedido(); | 70 | scope.seleccionarNotaPedido(); |
| 71 | 71 | ||
| 72 | //assert | 72 | //assert |
| 73 | expect(uibModal.open).toHaveBeenCalled(); | 73 | expect(uibModal.open).toHaveBeenCalled(); |
| 74 | }); | 74 | }); |
| 75 | 75 | ||
| 76 | it('La función seleccionarNotaPedido llama a broadCast en promesa', function(done) { | 76 | it('La función seleccionarNotaPedido llama a broadCast en promesa', function(done) { |
| 77 | //arrange | 77 | //arrange |
| 78 | var scope = { | 78 | var scope = { |
| 79 | $watch: function() { }, | 79 | $watch: function() { }, |
| 80 | $broadcast: function() { } | 80 | $broadcast: function() { } |
| 81 | }; | 81 | }; |
| 82 | var uibModal = { | 82 | var uibModal = { |
| 83 | open: function() { } | 83 | open: function() { } |
| 84 | }; | 84 | }; |
| 85 | 85 | ||
| 86 | $controler('notaPedidoCtrl', { | 86 | $controler('notaPedidoCtrl', { |
| 87 | $scope: scope, | 87 | $scope: scope, |
| 88 | $uibModal: uibModal, | 88 | $uibModal: uibModal, |
| 89 | $location: {}, | 89 | $location: {}, |
| 90 | $filter: filter, | 90 | $filter: filter, |
| 91 | $timeout: timeout, | 91 | $timeout: timeout, |
| 92 | crearNotaPedidoService: { | 92 | crearNotaPedidoService: { |
| 93 | getNumeroNotaPedido: function() { | 93 | getNumeroNotaPedido: function() { |
| 94 | return { | 94 | return { |
| 95 | then: function() { } | 95 | then: function() { } |
| 96 | }; | 96 | }; |
| 97 | }, | 97 | }, |
| 98 | getBotonera: function() { }, | 98 | getBotonera: function() { }, |
| 99 | getCotizacionByIdMoneda: function() { | 99 | getCotizacionByIdMoneda: function() { |
| 100 | return { | 100 | return { |
| 101 | then: function() { } | 101 | then: function() { } |
| 102 | }; | 102 | }; |
| 103 | } | 103 | } |
| 104 | }, | 104 | }, |
| 105 | focaBotoneraLateralService: {}, | 105 | focaBotoneraLateralService: {}, |
| 106 | focaModalService: {}, | 106 | focaModalService: {}, |
| 107 | notaPedidoBusinessService: { | 107 | notaPedidoBusinessService: { |
| 108 | plazoToString: function() { }, | 108 | plazoToString: function() { }, |
| 109 | calcularArticulos: function() { } | 109 | calcularArticulos: function() { } |
| 110 | }, | 110 | }, |
| 111 | $rootScope: { | 111 | $rootScope: { |
| 112 | $on: function() { } | 112 | $on: function() { } |
| 113 | }, | 113 | }, |
| 114 | focaSeguimientoService: {}, | 114 | focaSeguimientoService: {}, |
| 115 | APP: {}, | 115 | APP: {}, |
| 116 | focaLoginService: {}, | 116 | focaLoginService: {}, |
| 117 | $localStorage: {} | 117 | $localStorage: {} |
| 118 | }); | 118 | }); |
| 119 | var notaPedido = { | 119 | var notaPedido = { |
| 120 | cotizacion: { | 120 | cotizacion: { |
| 121 | moneda: {} | 121 | moneda: {} |
| 122 | }, | 122 | }, |
| 123 | cliente: {}, | 123 | cliente: {}, |
| 124 | vendedor: {}, | 124 | vendedor: {}, |
| 125 | proveedor: {}, | 125 | proveedor: {}, |
| 126 | notaPedidoPlazo: [], | 126 | notaPedidoPlazo: [], |
| 127 | notaPedidoPuntoDescarga: [] | 127 | notaPedidoPuntoDescarga: [] |
| 128 | }; | 128 | }; |
| 129 | var respuesta = { result: Promise.resolve(notaPedido) }; | 129 | var respuesta = { result: Promise.resolve(notaPedido) }; |
| 130 | 130 | ||
| 131 | //act | 131 | //act |
| 132 | scope.notaPedido = {}; | 132 | scope.notaPedido = {}; |
| 133 | scope.$broadcast = function() { }; | 133 | scope.$broadcast = function() { }; |
| 134 | spyOn(uibModal, 'open').and.returnValue(respuesta); | 134 | spyOn(uibModal, 'open').and.returnValue(respuesta); |
| 135 | spyOn(scope, '$broadcast'); | 135 | spyOn(scope, '$broadcast'); |
| 136 | scope.seleccionarNotaPedido(); | 136 | scope.seleccionarNotaPedido(); |
| 137 | 137 | ||
| 138 | //assert | 138 | //assert |
| 139 | respuesta.result.then(function() { | 139 | respuesta.result.then(function() { |
| 140 | expect(scope.$broadcast).toHaveBeenCalledWith('removeCabecera', 'Bomba:'); | 140 | expect(scope.$broadcast).toHaveBeenCalledWith('removeCabecera', 'Bomba:'); |
| 141 | expect(scope.$broadcast).toHaveBeenCalledWith('removeCabecera', 'Kilometros:'); | 141 | expect(scope.$broadcast).toHaveBeenCalledWith('removeCabecera', 'Kilometros:'); |
| 142 | done(); | 142 | done(); |
| 143 | }); | 143 | }); |
| 144 | }); | 144 | }); |
| 145 | 145 | ||
| 146 | it('función seleccionarProductos muestra alerta cuando idLista undefined', function() { | 146 | it('función seleccionarProductos muestra alerta cuando idLista undefined', function() { |
| 147 | //arrange | 147 | //arrange |
| 148 | var scope = { | 148 | var scope = { |
| 149 | $watch: function() { }, | 149 | $watch: function() { }, |
| 150 | $broadcast: function() { } | 150 | $broadcast: function() { } |
| 151 | }; | 151 | }; |
| 152 | var focaModalService = { | 152 | var focaModalService = { |
| 153 | alert: function() { } | 153 | alert: function() { } |
| 154 | }; | 154 | }; |
| 155 | 155 | ||
| 156 | $controler('notaPedidoCtrl', { | 156 | $controler('notaPedidoCtrl', { |
| 157 | $scope: scope, | 157 | $scope: scope, |
| 158 | $uibModal: {}, | 158 | $uibModal: {}, |
| 159 | $location: {}, | 159 | $location: {}, |
| 160 | $filter: filter, | 160 | $filter: filter, |
| 161 | $timeout: timeout, | 161 | $timeout: timeout, |
| 162 | crearNotaPedidoService: { | 162 | crearNotaPedidoService: { |
| 163 | getNumeroNotaPedido: function() { | 163 | getNumeroNotaPedido: function() { |
| 164 | return { | 164 | return { |
| 165 | then: function() { } | 165 | then: function() { } |
| 166 | }; | 166 | }; |
| 167 | }, | 167 | }, |
| 168 | getBotonera: function() { }, | 168 | getBotonera: function() { }, |
| 169 | getCotizacionByIdMoneda: function() { | 169 | getCotizacionByIdMoneda: function() { |
| 170 | return { | 170 | return { |
| 171 | then: function() { } | 171 | then: function() { } |
| 172 | }; | 172 | }; |
| 173 | } | 173 | } |
| 174 | }, | 174 | }, |
| 175 | focaBotoneraLateralService: {}, | 175 | focaBotoneraLateralService: {}, |
| 176 | focaModalService: focaModalService, | 176 | focaModalService: focaModalService, |
| 177 | notaPedidoBusinessService: {}, | 177 | notaPedidoBusinessService: {}, |
| 178 | $rootScope: { | 178 | $rootScope: { |
| 179 | $on: function() { } | 179 | $on: function() { } |
| 180 | }, | 180 | }, |
| 181 | focaSeguimientoService: {}, | 181 | focaSeguimientoService: {}, |
| 182 | APP: {}, | 182 | APP: {}, |
| 183 | focaLoginService: {}, | 183 | focaLoginService: {}, |
| 184 | $localStorage: {} | 184 | $localStorage: {} |
| 185 | }); | 185 | }); |
| 186 | 186 | ||
| 187 | //act | 187 | //act |
| 188 | spyOn(focaModalService, 'alert'); | 188 | spyOn(focaModalService, 'alert'); |
| 189 | scope.idLista = undefined; | 189 | scope.idLista = undefined; |
| 190 | scope.seleccionarProductos(); | 190 | scope.seleccionarProductos(); |
| 191 | 191 | ||
| 192 | //assert | 192 | //assert |
| 193 | expect(focaModalService.alert) | 193 | expect(focaModalService.alert) |
| 194 | .toHaveBeenCalledWith('Primero seleccione una lista de precio y condicion'); | 194 | .toHaveBeenCalledWith('Primero seleccione una lista de precio y condicion'); |
| 195 | }); | 195 | }); |
| 196 | 196 | ||
| 197 | it('función seleccionarProductos abre modal', function() { | 197 | it('función seleccionarProductos abre modal', function() { |
| 198 | //arrange | 198 | //arrange |
| 199 | var scope = { | 199 | var scope = { |
| 200 | $watch: function() { }, | 200 | $watch: function() { }, |
| 201 | $broadcast: function() { } | 201 | $broadcast: function() { } |
| 202 | }; | 202 | }; |
| 203 | var uibModal = { | 203 | var uibModal = { |
| 204 | open: function() { } | 204 | open: function() { } |
| 205 | }; | 205 | }; |
| 206 | 206 | ||
| 207 | $controler('notaPedidoCtrl', { | 207 | $controler('notaPedidoCtrl', { |
| 208 | $scope: scope, | 208 | $scope: scope, |
| 209 | $uibModal: uibModal, | 209 | $uibModal: uibModal, |
| 210 | $location: {}, | 210 | $location: {}, |
| 211 | $filter: filter, | 211 | $filter: filter, |
| 212 | $timeout: timeout, | 212 | $timeout: timeout, |
| 213 | crearNotaPedidoService: { | 213 | crearNotaPedidoService: { |
| 214 | getNumeroNotaPedido: function() { | 214 | getNumeroNotaPedido: function() { |
| 215 | return { | 215 | return { |
| 216 | then: function() { } | 216 | then: function() { } |
| 217 | }; | 217 | }; |
| 218 | }, | 218 | }, |
| 219 | getBotonera: function() { }, | 219 | getBotonera: function() { }, |
| 220 | getCotizacionByIdMoneda: function() { | 220 | getCotizacionByIdMoneda: function() { |
| 221 | return { | 221 | return { |
| 222 | then: function() { } | 222 | then: function() { } |
| 223 | }; | 223 | }; |
| 224 | } | 224 | } |
| 225 | }, | 225 | }, |
| 226 | focaBotoneraLateralService: {}, | 226 | focaBotoneraLateralService: {}, |
| 227 | focaModalService: {}, | 227 | focaModalService: {}, |
| 228 | notaPedidoBusinessService: {}, | 228 | notaPedidoBusinessService: {}, |
| 229 | $rootScope: { | 229 | $rootScope: { |
| 230 | $on: function() { } | 230 | $on: function() { } |
| 231 | }, | 231 | }, |
| 232 | focaSeguimientoService: {}, | 232 | focaSeguimientoService: {}, |
| 233 | APP: {}, | 233 | APP: {}, |
| 234 | focaLoginService: {}, | 234 | focaLoginService: {}, |
| 235 | $localStorage: {} | 235 | $localStorage: {} |
| 236 | }); | 236 | }); |
| 237 | scope.idLista = true; | 237 | scope.idLista = true; |
| 238 | scope.notaPedido = { | 238 | scope.notaPedido = { |
| 239 | cotizacion: { | 239 | cotizacion: { |
| 240 | moneda: {} | 240 | moneda: {} |
| 241 | }, | 241 | }, |
| 242 | 242 | ||
| 243 | }; | 243 | }; |
| 244 | var respuesta = { result: {then: function() { } } }; | 244 | var respuesta = { result: {then: function() { } } }; |
| 245 | 245 | ||
| 246 | //act | 246 | //act |
| 247 | spyOn(uibModal, 'open').and.returnValue(respuesta); | 247 | spyOn(uibModal, 'open').and.returnValue(respuesta); |
| 248 | scope.seleccionarProductos(); | 248 | scope.seleccionarProductos(); |
| 249 | 249 | ||
| 250 | //assert | 250 | //assert |
| 251 | expect(uibModal.open).toHaveBeenCalled(); | 251 | expect(uibModal.open).toHaveBeenCalled(); |
| 252 | }); | 252 | }); |
| 253 | 253 | ||
| 254 | it('función seleccionarPuntosDeDescarga muestra alerta cuando cliente y domicilio son' + | 254 | it('función seleccionarPuntosDeDescarga muestra alerta cuando cliente y domicilio son' + |
| 255 | 'undefined', function() | 255 | 'undefined', function() |
| 256 | { | 256 | { |
| 257 | //arrange | 257 | //arrange |
| 258 | var scope = { | 258 | var scope = { |
| 259 | $watch: function() { }, | 259 | $watch: function() { }, |
| 260 | $broadcast: function() { } | 260 | $broadcast: function() { } |
| 261 | }; | 261 | }; |
| 262 | var focaModalService = { | 262 | var focaModalService = { |
| 263 | alert: function() { } | 263 | alert: function() { } |
| 264 | }; | 264 | }; |
| 265 | 265 | ||
| 266 | $controler('notaPedidoCtrl', { | 266 | $controler('notaPedidoCtrl', { |
| 267 | $scope: scope, | 267 | $scope: scope, |
| 268 | $uibModal: {}, | 268 | $uibModal: {}, |
| 269 | $location: {}, | 269 | $location: {}, |
| 270 | $filter: filter, | 270 | $filter: filter, |
| 271 | $timeout: timeout, | 271 | $timeout: timeout, |
| 272 | crearNotaPedidoService: { | 272 | crearNotaPedidoService: { |
| 273 | getNumeroNotaPedido: function() { | 273 | getNumeroNotaPedido: function() { |
| 274 | return { | 274 | return { |
| 275 | then: function() { } | 275 | then: function() { } |
| 276 | }; | 276 | }; |
| 277 | }, | 277 | }, |
| 278 | getBotonera: function() { }, | 278 | getBotonera: function() { }, |
| 279 | getCotizacionByIdMoneda: function() { | 279 | getCotizacionByIdMoneda: function() { |
| 280 | return { | 280 | return { |
| 281 | then: function() { } | 281 | then: function() { } |
| 282 | }; | 282 | }; |
| 283 | } | 283 | } |
| 284 | }, | 284 | }, |
| 285 | focaBotoneraLateralService: {}, | 285 | focaBotoneraLateralService: {}, |
| 286 | focaModalService: focaModalService, | 286 | focaModalService: focaModalService, |
| 287 | notaPedidoBusinessService: {}, | 287 | notaPedidoBusinessService: {}, |
| 288 | $rootScope: { | 288 | $rootScope: { |
| 289 | $on: function() { } | 289 | $on: function() { } |
| 290 | }, | 290 | }, |
| 291 | focaSeguimientoService: {}, | 291 | focaSeguimientoService: {}, |
| 292 | APP: {}, | 292 | APP: {}, |
| 293 | focaLoginService: {}, | 293 | focaLoginService: {}, |
| 294 | $localStorage: {} | 294 | $localStorage: {} |
| 295 | }); | 295 | }); |
| 296 | scope.idLista = true; | 296 | scope.idLista = true; |
| 297 | scope.notaPedido = { | 297 | scope.notaPedido = { |
| 298 | cliente: { COD: false }, | 298 | cliente: { COD: false }, |
| 299 | domicilio: { id: false} | 299 | domicilio: { id: false} |
| 300 | }; | 300 | }; |
| 301 | 301 | ||
| 302 | //act | 302 | //act |
| 303 | spyOn(focaModalService, 'alert'); | 303 | spyOn(focaModalService, 'alert'); |
| 304 | scope.seleccionarPuntosDeDescarga(); | 304 | scope.seleccionarPuntosDeDescarga(); |
| 305 | 305 | ||
| 306 | //assert | 306 | //assert |
| 307 | expect(focaModalService.alert).toHaveBeenCalled(); | 307 | expect(focaModalService.alert).toHaveBeenCalled(); |
| 308 | }); | 308 | }); |
| 309 | 309 | ||
| 310 | it('función seleccionarPuntosDeDescarga abre modal', function() { | 310 | it('función seleccionarPuntosDeDescarga abre modal', function() { |
| 311 | //arrange | 311 | //arrange |
| 312 | var scope = { | 312 | var scope = { |
| 313 | $watch: function() { }, | 313 | $watch: function() { }, |
| 314 | $broadcast: function() { } | 314 | $broadcast: function() { } |
| 315 | }; | 315 | }; |
| 316 | var uibModal = { | 316 | var uibModal = { |
| 317 | open: function() { } | 317 | open: function() { } |
| 318 | }; | 318 | }; |
| 319 | 319 | ||
| 320 | $controler('notaPedidoCtrl', { | 320 | $controler('notaPedidoCtrl', { |
| 321 | $scope: scope, | 321 | $scope: scope, |
| 322 | $uibModal: uibModal, | 322 | $uibModal: uibModal, |
| 323 | $location: {}, | 323 | $location: {}, |
| 324 | $filter: filter, | 324 | $filter: filter, |
| 325 | $timeout: timeout, | 325 | $timeout: timeout, |
| 326 | crearNotaPedidoService: { | 326 | crearNotaPedidoService: { |
| 327 | getNumeroNotaPedido: function() { | 327 | getNumeroNotaPedido: function() { |
| 328 | return { | 328 | return { |
| 329 | then: function() { } | 329 | then: function() { } |
| 330 | }; | 330 | }; |
| 331 | }, | 331 | }, |
| 332 | getBotonera: function() { }, | 332 | getBotonera: function() { }, |
| 333 | getCotizacionByIdMoneda: function() { | 333 | getCotizacionByIdMoneda: function() { |
| 334 | return { | 334 | return { |
| 335 | then: function() { } | 335 | then: function() { } |
| 336 | }; | 336 | }; |
| 337 | } | 337 | } |
| 338 | }, | 338 | }, |
| 339 | focaBotoneraLateralService: {}, | 339 | focaBotoneraLateralService: {}, |
| 340 | focaModalService: {}, | 340 | focaModalService: {}, |
| 341 | notaPedidoBusinessService: {}, | 341 | notaPedidoBusinessService: {}, |
| 342 | $rootScope: { | 342 | $rootScope: { |
| 343 | $on: function() { } | 343 | $on: function() { } |
| 344 | }, | 344 | }, |
| 345 | focaSeguimientoService: {}, | 345 | focaSeguimientoService: {}, |
| 346 | APP: {}, | 346 | APP: {}, |
| 347 | focaLoginService: {}, | 347 | focaLoginService: {}, |
| 348 | $localStorage: {} | 348 | $localStorage: {} |
| 349 | }); | 349 | }); |
| 350 | scope.idLista = true; | 350 | scope.idLista = true; |
| 351 | scope.notaPedido = { | 351 | scope.notaPedido = { |
| 352 | cliente: { COD: true }, | 352 | cliente: { COD: true }, |
| 353 | domicilio: { id: true } | 353 | domicilio: { id: true } |
| 354 | }; | 354 | }; |
| 355 | var respuesta = { result: { then: function() { } } }; | 355 | var respuesta = { result: { then: function() { } } }; |
| 356 | 356 | ||
| 357 | //act | 357 | //act |
| 358 | spyOn(uibModal, 'open').and.returnValue(respuesta); | 358 | spyOn(uibModal, 'open').and.returnValue(respuesta); |
| 359 | scope.seleccionarPuntosDeDescarga(); | 359 | scope.seleccionarPuntosDeDescarga(); |
| 360 | 360 | ||
| 361 | //assert | 361 | //assert |
| 362 | expect(uibModal.open).toHaveBeenCalled(); | 362 | expect(uibModal.open).toHaveBeenCalled(); |
| 363 | }); | 363 | }); |
| 364 | 364 | ||
| 365 | it('función seleccionarPuntosDeDescarga setea punto elegido', function(done) { | 365 | it('función seleccionarPuntosDeDescarga setea punto elegido', function(done) { |
| 366 | //arrange | 366 | //arrange |
| 367 | var scope = { | 367 | var scope = { |
| 368 | $watch: function() { }, | 368 | $watch: function() { }, |
| 369 | $broadcast: function() { } | 369 | $broadcast: function() { } |
| 370 | }; | 370 | }; |
| 371 | var uibModal = { | 371 | var uibModal = { |
| 372 | open: function() { } | 372 | open: function() { } |
| 373 | }; | 373 | }; |
| 374 | 374 | ||
| 375 | $controler('notaPedidoCtrl', { | 375 | $controler('notaPedidoCtrl', { |
| 376 | $scope: scope, | 376 | $scope: scope, |
| 377 | $uibModal: uibModal, | 377 | $uibModal: uibModal, |
| 378 | $location: {}, | 378 | $location: {}, |
| 379 | $filter: filter, | 379 | $filter: filter, |
| 380 | $timeout: timeout, | 380 | $timeout: timeout, |
| 381 | crearNotaPedidoService: { | 381 | crearNotaPedidoService: { |
| 382 | getNumeroNotaPedido: function() { | 382 | getNumeroNotaPedido: function() { |
| 383 | return { | 383 | return { |
| 384 | then: function() { } | 384 | then: function() { } |
| 385 | }; | 385 | }; |
| 386 | }, | 386 | }, |
| 387 | getBotonera: function() { }, | 387 | getBotonera: function() { }, |
| 388 | getCotizacionByIdMoneda: function() { | 388 | getCotizacionByIdMoneda: function() { |
| 389 | return { | 389 | return { |
| 390 | then: function() { } | 390 | then: function() { } |
| 391 | }; | 391 | }; |
| 392 | } | 392 | } |
| 393 | }, | 393 | }, |
| 394 | focaBotoneraLateralService: {}, | 394 | focaBotoneraLateralService: {}, |
| 395 | focaModalService: {}, | 395 | focaModalService: {}, |
| 396 | notaPedidoBusinessService: {}, | 396 | notaPedidoBusinessService: {}, |
| 397 | $rootScope: { | 397 | $rootScope: { |
| 398 | $on: function() { } | 398 | $on: function() { } |
| 399 | }, | 399 | }, |
| 400 | focaSeguimientoService: {}, | 400 | focaSeguimientoService: {}, |
| 401 | APP: {}, | 401 | APP: {}, |
| 402 | focaLoginService: {}, | 402 | focaLoginService: {}, |
| 403 | $localStorage: {} | 403 | $localStorage: {} |
| 404 | }); | 404 | }); |
| 405 | scope.idLista = true; | 405 | scope.idLista = true; |
| 406 | scope.notaPedido = { | 406 | scope.notaPedido = { |
| 407 | cliente: { COD: true }, | 407 | cliente: { COD: true }, |
| 408 | domicilio: { id: true }, | 408 | domicilio: { id: true }, |
| 409 | puntosDescarga: [] | 409 | puntosDescarga: [] |
| 410 | }; | 410 | }; |
| 411 | var respuesta = []; | 411 | var respuesta = []; |
| 412 | var promiseRespuesta = { result: Promise.resolve(respuesta) }; | 412 | var promiseRespuesta = { result: Promise.resolve(respuesta) }; |
| 413 | scope.$broadcast = function() { }; | 413 | scope.$broadcast = function() { }; |
| 414 | 414 | ||
| 415 | //act | 415 | //act |
| 416 | spyOn(uibModal, 'open').and.returnValue(promiseRespuesta); | 416 | spyOn(uibModal, 'open').and.returnValue(promiseRespuesta); |
| 417 | scope.seleccionarPuntosDeDescarga(); | 417 | scope.seleccionarPuntosDeDescarga(); |
| 418 | 418 | ||
| 419 | //assert | 419 | //assert |
| 420 | promiseRespuesta.result.then(function() { | 420 | promiseRespuesta.result.then(function() { |
| 421 | expect(scope.notaPedido.puntosDescarga).toEqual(respuesta); | 421 | expect(scope.notaPedido.puntosDescarga).toEqual(respuesta); |
| 422 | done(); | 422 | done(); |
| 423 | }); | 423 | }); |
| 424 | }); | 424 | }); |
| 425 | 425 | ||
| 426 | it('función seleccionarVendedor abre modal', function() { | 426 | it('función seleccionarVendedor abre modal', function() { |
| 427 | //arrange | 427 | //arrange |
| 428 | var scope = { | 428 | var scope = { |
| 429 | $watch: function() { }, | 429 | $watch: function() { }, |
| 430 | $broadcast: function() { } | 430 | $broadcast: function() { } |
| 431 | }; | 431 | }; |
| 432 | var focaModalService = { | 432 | var focaModalService = { |
| 433 | modal: function() { } | 433 | modal: function() { } |
| 434 | }; | 434 | }; |
| 435 | 435 | ||
| 436 | $controler('notaPedidoCtrl', { | 436 | $controler('notaPedidoCtrl', { |
| 437 | $scope: scope, | 437 | $scope: scope, |
| 438 | $uibModal: {}, | 438 | $uibModal: {}, |
| 439 | $location: {}, | 439 | $location: {}, |
| 440 | $filter: filter, | 440 | $filter: filter, |
| 441 | $timeout: timeout, | 441 | $timeout: timeout, |
| 442 | crearNotaPedidoService: { | 442 | crearNotaPedidoService: { |
| 443 | getNumeroNotaPedido: function() { | 443 | getNumeroNotaPedido: function() { |
| 444 | return { | 444 | return { |
| 445 | then: function() { } | 445 | then: function() { } |
| 446 | }; | 446 | }; |
| 447 | }, | 447 | }, |
| 448 | getBotonera: function() { }, | 448 | getBotonera: function() { }, |
| 449 | getCotizacionByIdMoneda: function() { | 449 | getCotizacionByIdMoneda: function() { |
| 450 | return { | 450 | return { |
| 451 | then: function() { } | 451 | then: function() { } |
| 452 | }; | 452 | }; |
| 453 | } | 453 | } |
| 454 | }, | 454 | }, |
| 455 | focaBotoneraLateralService: {}, | 455 | focaBotoneraLateralService: {}, |
| 456 | focaModalService: focaModalService, | 456 | focaModalService: focaModalService, |
| 457 | notaPedidoBusinessService: {}, | 457 | notaPedidoBusinessService: {}, |
| 458 | $rootScope: { | 458 | $rootScope: { |
| 459 | $on: function() { } | 459 | $on: function() { } |
| 460 | }, | 460 | }, |
| 461 | focaSeguimientoService: {}, | 461 | focaSeguimientoService: {}, |
| 462 | APP: {}, | 462 | APP: {}, |
| 463 | focaLoginService: {}, | 463 | focaLoginService: {}, |
| 464 | $localStorage: {} | 464 | $localStorage: {} |
| 465 | }); | 465 | }); |
| 466 | scope.idLista = true; | 466 | scope.idLista = true; |
| 467 | scope.notaPedido = { | 467 | scope.notaPedido = { |
| 468 | cliente: { COD: true }, | 468 | cliente: { COD: true }, |
| 469 | domicilio: { id: true } | 469 | domicilio: { id: true } |
| 470 | }; | 470 | }; |
| 471 | 471 | ||
| 472 | var respuesta = { then: function() { } }; | 472 | var respuesta = { then: function() { } }; |
| 473 | 473 | ||
| 474 | //act | 474 | //act |
| 475 | spyOn(focaModalService, 'modal').and.returnValue(respuesta); | 475 | spyOn(focaModalService, 'modal').and.returnValue(respuesta); |
| 476 | scope.seleccionarVendedor(); | 476 | scope.seleccionarVendedor(); |
| 477 | 477 | ||
| 478 | //assert | 478 | //assert |
| 479 | expect(focaModalService.modal).toHaveBeenCalled(); | 479 | expect(focaModalService.modal).toHaveBeenCalled(); |
| 480 | }); | 480 | }); |
| 481 | 481 | ||
| 482 | it('función seleccionarVendedor setea vendedor y cabecera', function(done) { | 482 | it('función seleccionarVendedor setea vendedor y cabecera', function(done) { |
| 483 | //arrange | 483 | //arrange |
| 484 | var scope = { | 484 | var scope = { |
| 485 | $watch: function() { }, | 485 | $watch: function() { }, |
| 486 | $broadcast: function() { } | 486 | $broadcast: function() { } |
| 487 | }; | 487 | }; |
| 488 | var focaModalService = { | 488 | var focaModalService = { |
| 489 | modal: function() { } | 489 | modal: function() { } |
| 490 | }; | 490 | }; |
| 491 | 491 | ||
| 492 | $controler('notaPedidoCtrl', { | 492 | $controler('notaPedidoCtrl', { |
| 493 | $scope: scope, | 493 | $scope: scope, |
| 494 | $uibModal: {}, | 494 | $uibModal: {}, |
| 495 | $location: {}, | 495 | $location: {}, |
| 496 | $filter: filter, | 496 | $filter: filter, |
| 497 | $timeout: timeout, | 497 | $timeout: timeout, |
| 498 | crearNotaPedidoService: { | 498 | crearNotaPedidoService: { |
| 499 | getNumeroNotaPedido: function() { | 499 | getNumeroNotaPedido: function() { |
| 500 | return { | 500 | return { |
| 501 | then: function() { } | 501 | then: function() { } |
| 502 | }; | 502 | }; |
| 503 | }, | 503 | }, |
| 504 | getBotonera: function() { }, | 504 | getBotonera: function() { }, |
| 505 | getCotizacionByIdMoneda: function() { | 505 | getCotizacionByIdMoneda: function() { |
| 506 | return { | 506 | return { |
| 507 | then: function() { } | 507 | then: function() { } |
| 508 | }; | 508 | }; |
| 509 | } | 509 | } |
| 510 | }, | 510 | }, |
| 511 | focaBotoneraLateralService: {}, | 511 | focaBotoneraLateralService: {}, |
| 512 | focaModalService: focaModalService, | 512 | focaModalService: focaModalService, |
| 513 | notaPedidoBusinessService: {}, | 513 | notaPedidoBusinessService: {}, |
| 514 | $rootScope: { | 514 | $rootScope: { |
| 515 | $on: function() { } | 515 | $on: function() { } |
| 516 | }, | 516 | }, |
| 517 | focaSeguimientoService: {}, | 517 | focaSeguimientoService: {}, |
| 518 | APP: {}, | 518 | APP: {}, |
| 519 | focaLoginService: {}, | 519 | focaLoginService: {}, |
| 520 | $localStorage: {} | 520 | $localStorage: {} |
| 521 | }); | 521 | }); |
| 522 | scope.idLista = true; | 522 | scope.idLista = true; |
| 523 | scope.notaPedido = { | 523 | scope.notaPedido = { |
| 524 | cliente: { COD: true }, | 524 | cliente: { COD: true }, |
| 525 | domicilio: { id: true } | 525 | domicilio: { id: true } |
| 526 | }; | 526 | }; |
| 527 | var respuesta = {}; | 527 | var respuesta = {}; |
| 528 | var promesaRespuesta = Promise.resolve(respuesta); | 528 | var promesaRespuesta = Promise.resolve(respuesta); |
| 529 | scope.$broadcast = function() { }; | 529 | scope.$broadcast = function() { }; |
| 530 | 530 | ||
| 531 | //act | 531 | //act |
| 532 | spyOn(focaModalService, 'modal').and.returnValue(promesaRespuesta); | 532 | spyOn(focaModalService, 'modal').and.returnValue(promesaRespuesta); |
| 533 | spyOn(scope, '$broadcast'); | 533 | spyOn(scope, '$broadcast'); |
| 534 | scope.seleccionarVendedor(); | 534 | scope.seleccionarVendedor(); |
| 535 | 535 | ||
| 536 | //assert | 536 | //assert |
| 537 | promesaRespuesta.then(function() { | 537 | promesaRespuesta.then(function() { |
| 538 | expect(scope.notaPedido.vendedor).toEqual(respuesta); | 538 | expect(scope.notaPedido.vendedor).toEqual(respuesta); |
| 539 | expect(scope.$broadcast).toHaveBeenCalled(); | 539 | expect(scope.$broadcast).toHaveBeenCalled(); |
| 540 | done(); | 540 | done(); |
| 541 | }); | 541 | }); |
| 542 | }); | 542 | }); |
| 543 | 543 | ||
| 544 | it('función seleccionarProveedor abre modal', function() { | 544 | it('función seleccionarProveedor abre modal', function() { |
| 545 | //arrange | 545 | //arrange |
| 546 | var scope = { | 546 | var scope = { |
| 547 | $watch: function() { }, | 547 | $watch: function() { }, |
| 548 | $broadcast: function() { } | 548 | $broadcast: function() { } |
| 549 | }; | 549 | }; |
| 550 | var focaModalService = { | 550 | var focaModalService = { |
| 551 | modal: function() { } | 551 | modal: function() { } |
| 552 | }; | 552 | }; |
| 553 | 553 | ||
| 554 | $controler('notaPedidoCtrl', { | 554 | $controler('notaPedidoCtrl', { |
| 555 | $scope: scope, | 555 | $scope: scope, |
| 556 | $uibModal: {}, | 556 | $uibModal: {}, |
| 557 | $location: {}, | 557 | $location: {}, |
| 558 | $filter: filter, | 558 | $filter: filter, |
| 559 | $timeout: timeout, | 559 | $timeout: timeout, |
| 560 | crearNotaPedidoService: { | 560 | crearNotaPedidoService: { |
| 561 | getNumeroNotaPedido: function() { | 561 | getNumeroNotaPedido: function() { |
| 562 | return { | 562 | return { |
| 563 | then: function() { } | 563 | then: function() { } |
| 564 | }; | 564 | }; |
| 565 | }, | 565 | }, |
| 566 | getBotonera: function() { }, | 566 | getBotonera: function() { }, |
| 567 | getCotizacionByIdMoneda: function() { | 567 | getCotizacionByIdMoneda: function() { |
| 568 | return { | 568 | return { |
| 569 | then: function() { } | 569 | then: function() { } |
| 570 | }; | 570 | }; |
| 571 | } | 571 | } |
| 572 | }, | 572 | }, |
| 573 | focaBotoneraLateralService: {}, | 573 | focaBotoneraLateralService: {}, |
| 574 | focaModalService: focaModalService, | 574 | focaModalService: focaModalService, |
| 575 | notaPedidoBusinessService: {}, | 575 | notaPedidoBusinessService: {}, |
| 576 | $rootScope: { | 576 | $rootScope: { |
| 577 | $on: function() { } | 577 | $on: function() { } |
| 578 | }, | 578 | }, |
| 579 | focaSeguimientoService: {}, | 579 | focaSeguimientoService: {}, |
| 580 | APP: {}, | 580 | APP: {}, |
| 581 | focaLoginService: {}, | 581 | focaLoginService: {}, |
| 582 | $localStorage: {} | 582 | $localStorage: {} |
| 583 | }); | 583 | }); |
| 584 | scope.notaPedido = {}; | 584 | scope.notaPedido = {}; |
| 585 | 585 | ||
| 586 | var respuesta = { then: function() { } }; | 586 | var respuesta = { then: function() { } }; |
| 587 | 587 | ||
| 588 | //act | 588 | //act |
| 589 | spyOn(focaModalService, 'modal').and.returnValue(respuesta); | 589 | spyOn(focaModalService, 'modal').and.returnValue(respuesta); |
| 590 | scope.seleccionarProveedor(); | 590 | scope.seleccionarProveedor(); |
| 591 | 591 | ||
| 592 | //assert | 592 | //assert |
| 593 | expect(focaModalService.modal).toHaveBeenCalled(); | 593 | expect(focaModalService.modal).toHaveBeenCalled(); |
| 594 | }); | 594 | }); |
| 595 | 595 | ||
| 596 | it('función seleccionarProveedor setea vendedor y cabecera', function(done) { | 596 | it('función seleccionarProveedor setea vendedor y cabecera', function(done) { |
| 597 | //arrange | 597 | //arrange |
| 598 | var scope = { | 598 | var scope = { |
| 599 | $watch: function() { }, | 599 | $watch: function() { }, |
| 600 | $broadcast: function() { } | 600 | $broadcast: function() { } |
| 601 | }; | 601 | }; |
| 602 | var focaModalService = { | 602 | var focaModalService = { |
| 603 | modal: function() { } | 603 | modal: function() { } |
| 604 | }; | 604 | }; |
| 605 | 605 | ||
| 606 | $controler('notaPedidoCtrl', { | 606 | $controler('notaPedidoCtrl', { |
| 607 | $scope: scope, | 607 | $scope: scope, |
| 608 | $uibModal: {}, | 608 | $uibModal: {}, |
| 609 | $location: {}, | 609 | $location: {}, |
| 610 | $filter: filter, | 610 | $filter: filter, |
| 611 | $timeout: timeout, | 611 | $timeout: timeout, |
| 612 | crearNotaPedidoService: { | 612 | crearNotaPedidoService: { |
| 613 | getNumeroNotaPedido: function() { | 613 | getNumeroNotaPedido: function() { |
| 614 | return { | 614 | return { |
| 615 | then: function() { } | 615 | then: function() { } |
| 616 | }; | 616 | }; |
| 617 | }, | 617 | }, |
| 618 | getBotonera: function() { }, | 618 | getBotonera: function() { }, |
| 619 | getCotizacionByIdMoneda: function() { | 619 | getCotizacionByIdMoneda: function() { |
| 620 | return { | 620 | return { |
| 621 | then: function() { } | 621 | then: function() { } |
| 622 | }; | 622 | }; |
| 623 | } | 623 | } |
| 624 | }, | 624 | }, |
| 625 | focaBotoneraLateralService: {}, | 625 | focaBotoneraLateralService: {}, |
| 626 | focaModalService: focaModalService, | 626 | focaModalService: focaModalService, |
| 627 | notaPedidoBusinessService: {}, | 627 | notaPedidoBusinessService: {}, |
| 628 | $rootScope: { | 628 | $rootScope: { |
| 629 | $on: function() { } | 629 | $on: function() { } |
| 630 | }, | 630 | }, |
| 631 | focaSeguimientoService: {}, | 631 | focaSeguimientoService: {}, |
| 632 | APP: {}, | 632 | APP: {}, |
| 633 | focaLoginService: {}, | 633 | focaLoginService: {}, |
| 634 | $localStorage: {} | 634 | $localStorage: {} |
| 635 | }); | 635 | }); |
| 636 | 636 | ||
| 637 | scope.notaPedido = {}; | 637 | scope.notaPedido = {}; |
| 638 | var respuesta = {}; | 638 | var respuesta = {}; |
| 639 | var promesaRespuesta = Promise.resolve(respuesta); | 639 | var promesaRespuesta = Promise.resolve(respuesta); |
| 640 | scope.$broadcast = function() { }; | 640 | scope.$broadcast = function() { }; |
| 641 | 641 | ||
| 642 | //act | 642 | //act |
| 643 | spyOn(focaModalService, 'modal').and.returnValue(promesaRespuesta); | 643 | spyOn(focaModalService, 'modal').and.returnValue(promesaRespuesta); |
| 644 | spyOn(scope, '$broadcast'); | 644 | spyOn(scope, '$broadcast'); |
| 645 | scope.seleccionarProveedor(); | 645 | scope.seleccionarProveedor(); |
| 646 | 646 | ||
| 647 | //assert | 647 | //assert |
| 648 | promesaRespuesta.then(function() { | 648 | promesaRespuesta.then(function() { |
| 649 | expect(scope.notaPedido.proveedor).toEqual(respuesta); | 649 | expect(scope.notaPedido.proveedor).toEqual(respuesta); |
| 650 | expect(scope.$broadcast).toHaveBeenCalled(); | 650 | expect(scope.$broadcast).toHaveBeenCalled(); |
| 651 | done(); | 651 | done(); |
| 652 | }); | 652 | }); |
| 653 | }); | 653 | }); |
| 654 | 654 | ||
| 655 | it('función seleccionarCliente abre alerta cuando no se elije vendedor', function() { | ||
| 656 | //arrange | ||
| 657 | var scope = { | ||
| 658 | $watch: function() { }, | ||
| 659 | $broadcast: function() { } | ||
| 660 | }; | ||
| 661 | var focaModalService = { | ||
| 662 | alert: function() { } | ||
| 663 | }; | ||
| 664 | |||
| 665 | $controler('notaPedidoCtrl', { | ||
| 666 | $scope: scope, | ||
| 667 | $uibModal: {}, | ||
| 668 | $location: {}, | ||
| 669 | $filter: filter, | ||
| 670 | $timeout: timeout, | ||
| 671 | crearNotaPedidoService: { | ||
| 672 | getNumeroNotaPedido: function() { | ||
| 673 | return { | ||
| 674 | then: function() { } | ||
| 675 | }; | ||
| 676 | }, | ||
| 677 | getBotonera: function() { }, | ||
| 678 | getCotizacionByIdMoneda: function() { | ||
| 679 | return { | ||
| 680 | then: function() { } | ||
| 681 | }; | ||
| 682 | } | ||
| 683 | }, | ||
| 684 | focaBotoneraLateralService: {}, | ||
| 685 | focaModalService: focaModalService, | ||
| 686 | notaPedidoBusinessService: {}, | ||
| 687 | $rootScope: { | ||
| 688 | $on: function() { } | ||
| 689 | }, | ||
| 690 | focaSeguimientoService: {}, | ||
| 691 | APP: {}, | ||
| 692 | focaLoginService: {}, | ||
| 693 | $localStorage: {} | ||
| 694 | }); | ||
| 695 | scope.notaPedido = { | ||
| 696 | vendedor: { NUM: false } | ||
| 697 | }; | ||
| 698 | |||
| 699 | //act | ||
| 700 | spyOn(focaModalService, 'alert'); | ||
| 701 | scope.seleccionarCliente(); | ||
| 702 | |||
| 703 | //assert | ||
| 704 | expect(focaModalService.alert).toHaveBeenCalledWith('Primero seleccione un vendedor'); | ||
| 705 | }); | ||
| 706 | |||
| 707 | it('función seleccionarCliente abre modal', function() { | 655 | it('función seleccionarCliente abre modal', function() { |
| 708 | //arrange | 656 | //arrange |
| 709 | var scope = { | 657 | var scope = { |
| 710 | $watch: function() { }, | 658 | $watch: function() { }, |
| 711 | $broadcast: function() { } | 659 | $broadcast: function() { } |
| 712 | }; | 660 | }; |
| 713 | var uibModal = { | 661 | var uibModal = { |
| 714 | open: function() { } | 662 | open: function() { } |
| 715 | }; | 663 | }; |
| 716 | 664 | ||
| 717 | $controler('notaPedidoCtrl', { | 665 | $controler('notaPedidoCtrl', { |
| 718 | $scope: scope, | 666 | $scope: scope, |
| 719 | $uibModal: uibModal, | 667 | $uibModal: uibModal, |
| 720 | $location: {}, | 668 | $location: {}, |
| 721 | $filter: filter, | 669 | $filter: filter, |
| 722 | $timeout: timeout, | 670 | $timeout: timeout, |
| 723 | crearNotaPedidoService: { | 671 | crearNotaPedidoService: { |
| 724 | getNumeroNotaPedido: function() { | 672 | getNumeroNotaPedido: function() { |
| 725 | return { | 673 | return { |
| 726 | then: function() { } | 674 | then: function() { } |
| 727 | }; | 675 | }; |
| 728 | }, | 676 | }, |
| 729 | getBotonera: function() { }, | 677 | getBotonera: function() { }, |
| 730 | getCotizacionByIdMoneda: function() { | 678 | getCotizacionByIdMoneda: function() { |
| 731 | return { | 679 | return { |
| 732 | then: function() { } | 680 | then: function() { } |
| 733 | }; | 681 | }; |
| 682 | }, | ||
| 683 | getVendedorById: function() { | ||
| 684 | return { | ||
| 685 | then: function() { } | ||
| 686 | }; | ||
| 734 | } | 687 | } |
| 735 | }, | 688 | }, |
| 736 | focaBotoneraLateralService: {}, | 689 | focaBotoneraLateralService: {}, |
| 737 | focaModalService: {}, | 690 | focaModalService: { |
| 691 | modal: function() { | ||
| 692 | return { | ||
| 693 | then: function() {} | ||
| 694 | }; | ||
| 695 | } | ||
| 696 | }, | ||
| 738 | notaPedidoBusinessService: {}, | 697 | notaPedidoBusinessService: {}, |
| 739 | $rootScope: { | 698 | $rootScope: { |
| 740 | $on: function() { } | 699 | $on: function() { } |
| 741 | }, | 700 | }, |
| 742 | focaSeguimientoService: {}, | 701 | focaSeguimientoService: {}, |
| 743 | APP: {}, | 702 | APP: 'distribuidor', |
| 744 | focaLoginService: {}, | 703 | focaLoginService: { |
| 704 | getLoginData: function() { | ||
| 705 | return { | ||
| 706 | vendedorCorbrador: true | ||
| 707 | }; | ||
| 708 | } | ||
| 709 | }, | ||
| 745 | $localStorage: {} | 710 | $localStorage: {} |
| 746 | }); | 711 | }); |
| 747 | scope.notaPedido = { | 712 | scope.notaPedido = { |
| 748 | vendedor: { NUM: true } | 713 | vendedor: { NUM: true } |
| 749 | }; | 714 | }; |
| 750 | 715 | ||
| 751 | var respuesta = { result: {then: function() { } } }; | 716 | var respuesta = { result: {then: function() { } } }; |
| 752 | 717 | ||
| 753 | //act | 718 | //act |
| 754 | spyOn(uibModal, 'open').and.returnValue(respuesta); | 719 | spyOn(uibModal, 'open').and.returnValue(respuesta); |
| 755 | scope.seleccionarCliente(); | 720 | scope.seleccionarCliente(); |
| 756 | 721 | ||
| 757 | //assert | 722 | //assert |
| 758 | expect(uibModal.open).toHaveBeenCalled(); | 723 | expect(uibModal.open).toHaveBeenCalled(); |
| 759 | }); | 724 | }); |
| 760 | 725 | ||
| 761 | it('función seleccionarCliente setea vendedor y llama a domicilios', function(done) { | 726 | it('función seleccionarCliente setea vendedor y llama a domicilios', function(done) { |
| 762 | 727 | ||
| 763 | //arrange | 728 | //arrange |
| 764 | var scope = { | 729 | var scope = { |
| 765 | $watch: function() { }, | 730 | $watch: function() { }, |
| 766 | $broadcast: function() { } | 731 | $broadcast: function() { }, |
| 732 | seleccionarVendedor: function() { }, | ||
| 733 | notaPedido: {} | ||
| 767 | }; | 734 | }; |
| 768 | var uibModal = { | 735 | var uibModal = { |
| 769 | open: function() { } | 736 | open: function() { } |
| 770 | }; | 737 | }; |
| 771 | 738 | ||
| 772 | $controler('notaPedidoCtrl', { | 739 | $controler('notaPedidoCtrl', { |
| 773 | $scope: scope, | 740 | $scope: scope, |
| 774 | $uibModal: uibModal, | 741 | $uibModal: uibModal, |
| 775 | $location: {}, | 742 | $location: {}, |
| 776 | $filter: filter, | 743 | $filter: filter, |
| 777 | $timeout: timeout, | 744 | $timeout: timeout, |
| 778 | crearNotaPedidoService: { | 745 | crearNotaPedidoService: { |
| 779 | getNumeroNotaPedido: function() { | 746 | getNumeroNotaPedido: function() { |
| 780 | return { | 747 | return { |
| 781 | then: function() { } | 748 | then: function() { } |
| 782 | }; | 749 | }; |
| 783 | }, | 750 | }, |
| 784 | getBotonera: function() { }, | 751 | getBotonera: function() { }, |
| 785 | getCotizacionByIdMoneda: function() { | 752 | getCotizacionByIdMoneda: function() { |
| 786 | return { | 753 | return { |
| 787 | then: function() { } | 754 | then: function() { } |
| 788 | }; | 755 | }; |
| 756 | }, | ||
| 757 | getVendedorById : function() { | ||
| 758 | return { | ||
| 759 | then: function() { } | ||
| 760 | }; | ||
| 789 | } | 761 | } |
| 790 | }, | 762 | }, |
| 791 | focaBotoneraLateralService: {}, | 763 | focaBotoneraLateralService: {}, |
| 792 | focaModalService: {}, | 764 | focaModalService: { |
| 765 | modal: function() { | ||
| 766 | return { | ||
| 767 | then: function() { } | ||
| 768 | }; | ||
| 769 | } | ||
| 770 | }, | ||
| 793 | notaPedidoBusinessService: {}, | 771 | notaPedidoBusinessService: {}, |
| 794 | $rootScope: { | 772 | $rootScope: { |
| 795 | $on: function() { } | 773 | $on: function() { } |
| 796 | }, | 774 | }, |
| 797 | focaSeguimientoService: {}, | 775 | focaSeguimientoService: {}, |
| 798 | APP: {}, | 776 | APP: 'distribuidor', |
| 799 | focaLoginService: {}, | 777 | focaLoginService: { |
| 778 | getLoginData: function() { | ||
| 779 | return { | ||
| 780 | vendedorCorbrador: true | ||
| 781 | }; | ||
| 782 | } | ||
| 783 | }, | ||
| 800 | $localStorage: {} | 784 | $localStorage: {} |
| 801 | }); | 785 | }); |
| 802 | scope.idLista = true; | 786 | scope.idLista = true; |
| 803 | scope.notaPedido = { | 787 | scope.notaPedido = { |
| 804 | vendedor: { NUM: true } | 788 | vendedor: { NUM: true } |
| 805 | }; | 789 | }; |
| 806 | var respuesta = {}; | 790 | var respuesta = {}; |
| 807 | var promesaRespuesta = { result: Promise.resolve(respuesta) }; | 791 | var promesaRespuesta = { result: Promise.resolve(respuesta) }; |
| 808 | 792 | ||
| 809 | //act | 793 | //act |
| 810 | spyOn(uibModal, 'open').and.returnValue(promesaRespuesta); | 794 | spyOn(uibModal, 'open').and.returnValue(promesaRespuesta); |
| 811 | spyOn(scope, 'abrirModalDomicilios'); | 795 | spyOn(scope, 'abrirModalDomicilios'); |
| 812 | scope.seleccionarCliente(); | 796 | scope.seleccionarCliente(); |
| 813 | 797 | ||
| 814 | //assert | 798 | //assert |
| 815 | promesaRespuesta.result.then(function() { | 799 | promesaRespuesta.result.then(function() { |
| 816 | expect(scope.cliente).toEqual(respuesta); | 800 | expect(scope.cliente).toEqual(respuesta); |
| 817 | expect(scope.abrirModalDomicilios).toHaveBeenCalled(); | 801 | expect(scope.abrirModalDomicilios).toHaveBeenCalled(); |
| 818 | done(); | 802 | done(); |
| 819 | }); | 803 | }); |
| 820 | }); | 804 | }); |
| 821 | 805 | ||
| 822 | it('función abrirModalDomicilios abre modal', function() { | 806 | it('función abrirModalDomicilios abre modal', function() { |
| 823 | //arrange | 807 | //arrange |
| 824 | var scope = { | 808 | var scope = { |
| 825 | $watch: function() { }, | 809 | $watch: function() { }, |
| 826 | $broadcast: function() { } | 810 | $broadcast: function() { } |
| 827 | }; | 811 | }; |
| 828 | var uibModal = { | 812 | var uibModal = { |
| 829 | open: function() { } | 813 | open: function() { } |
| 830 | }; | 814 | }; |
| 831 | 815 | ||
| 832 | $controler('notaPedidoCtrl', { | 816 | $controler('notaPedidoCtrl', { |
| 833 | $scope: scope, | 817 | $scope: scope, |
| 834 | $uibModal: uibModal, | 818 | $uibModal: uibModal, |
| 835 | $location: {}, | 819 | $location: {}, |
| 836 | $filter: filter, | 820 | $filter: filter, |
| 837 | $timeout: timeout, | 821 | $timeout: timeout, |
| 838 | crearNotaPedidoService: { | 822 | crearNotaPedidoService: { |
| 839 | getNumeroNotaPedido: function() { | 823 | getNumeroNotaPedido: function() { |
| 840 | return { | 824 | return { |
| 841 | then: function() { } | 825 | then: function() { } |
| 842 | }; | 826 | }; |
| 843 | }, | 827 | }, |
| 844 | getBotonera: function() { }, | 828 | getBotonera: function() { }, |
| 845 | getCotizacionByIdMoneda: function() { | 829 | getCotizacionByIdMoneda: function() { |
| 846 | return { | 830 | return { |
| 847 | then: function() { } | 831 | then: function() { } |
| 848 | }; | 832 | }; |
| 849 | } | 833 | } |
| 850 | }, | 834 | }, |
| 851 | focaBotoneraLateralService: {}, | 835 | focaBotoneraLateralService: {}, |
| 852 | focaModalService: {}, | 836 | focaModalService: {}, |
| 853 | notaPedidoBusinessService: {}, | 837 | notaPedidoBusinessService: {}, |
| 854 | $rootScope: { | 838 | $rootScope: { |
| 855 | $on: function() { } | 839 | $on: function() { } |
| 856 | }, | 840 | }, |
| 857 | focaSeguimientoService: {}, | 841 | focaSeguimientoService: {}, |
| 858 | APP: {}, | 842 | APP: {}, |
| 859 | focaLoginService: {}, | 843 | focaLoginService: {}, |
| 860 | $localStorage: {} | 844 | $localStorage: {} |
| 861 | }); | 845 | }); |
| 862 | 846 | ||
| 863 | var respuesta = { result: {then: function() { } } }; | 847 | var respuesta = { result: {then: function() { } } }; |
| 864 | 848 | ||
| 865 | //act | 849 | //act |
| 866 | spyOn(uibModal, 'open').and.returnValue(respuesta); | 850 | spyOn(uibModal, 'open').and.returnValue(respuesta); |
| 867 | scope.abrirModalDomicilios(); | 851 | scope.abrirModalDomicilios(); |
| 868 | 852 | ||
| 869 | //assert | 853 | //assert |
| 870 | expect(uibModal.open).toHaveBeenCalled(); | 854 | expect(uibModal.open).toHaveBeenCalled(); |
| 871 | }); | 855 | }); |
| 872 | 856 | ||
| 873 | it('función abrirModalDomicilios setea domicilio, cliente y cabeceras', function(done) { | 857 | it('función abrirModalDomicilios setea domicilio, cliente y cabeceras', function(done) { |
| 874 | 858 | ||
| 875 | //arrange | 859 | //arrange |
| 876 | var scope = { | 860 | var scope = { |
| 877 | $watch: function() { }, | 861 | $watch: function() { }, |
| 878 | $broadcast: function() { } | 862 | $broadcast: function() { } |
| 879 | }; | 863 | }; |
| 880 | var uibModal = { | 864 | var uibModal = { |
| 881 | open: function() { } | 865 | open: function() { } |
| 882 | }; | 866 | }; |
| 883 | 867 | ||
| 884 | $controler('notaPedidoCtrl', { | 868 | $controler('notaPedidoCtrl', { |
| 885 | $scope: scope, | 869 | $scope: scope, |
| 886 | $uibModal: uibModal, | 870 | $uibModal: uibModal, |
| 887 | $location: {}, | 871 | $location: {}, |
| 888 | $filter: filter, | 872 | $filter: filter, |
| 889 | $timeout: timeout, | 873 | $timeout: timeout, |
| 890 | crearNotaPedidoService: { | 874 | crearNotaPedidoService: { |
| 891 | getNumeroNotaPedido: function() { | 875 | getNumeroNotaPedido: function() { |
| 892 | return { | 876 | return { |
| 893 | then: function() { } | 877 | then: function() { } |
| 894 | }; | 878 | }; |
| 895 | }, | 879 | }, |
| 896 | getBotonera: function() { }, | 880 | getBotonera: function() { }, |
| 897 | getCotizacionByIdMoneda: function() { | 881 | getCotizacionByIdMoneda: function() { |
| 898 | return { | 882 | return { |
| 899 | then: function() { } | 883 | then: function() { } |
| 900 | }; | 884 | }; |
| 901 | }, | 885 | }, |
| 902 | getPuntosDescargaByClienDom: function() { | 886 | getPuntosDescargaByClienDom: function() { |
| 903 | return { | 887 | return { |
| 904 | then: function() { } | 888 | then: function() { } |
| 905 | }; | 889 | }; |
| 906 | } | 890 | } |
| 907 | }, | 891 | }, |
| 908 | focaBotoneraLateralService: {}, | 892 | focaBotoneraLateralService: {}, |
| 909 | focaModalService: {}, | 893 | focaModalService: {}, |
| 910 | notaPedidoBusinessService: {}, | 894 | notaPedidoBusinessService: {}, |
| 911 | $rootScope: { | 895 | $rootScope: { |
| 912 | $on: function() { } | 896 | $on: function() { } |
| 913 | }, | 897 | }, |
| 914 | focaSeguimientoService: {}, | 898 | focaSeguimientoService: {}, |
| 915 | APP: {}, | 899 | APP: {}, |
| 916 | focaLoginService: {}, | 900 | focaLoginService: {}, |
| 917 | $localStorage: {} | 901 | $localStorage: {} |
| 918 | }); | 902 | }); |
| 919 | scope.idLista = true; | 903 | scope.idLista = true; |
| 920 | scope.notaPedido = { | 904 | scope.notaPedido = { |
| 921 | vendedor: { NUM: true } | 905 | vendedor: { NUM: true } |
| 922 | }; | 906 | }; |
| 923 | var respuesta = {}; | 907 | var respuesta = {}; |
| 924 | var promesaRespuesta = { result: Promise.resolve(respuesta) }; | 908 | var promesaRespuesta = { result: Promise.resolve(respuesta) }; |
| 925 | scope.$broadcast = function() { }; | 909 | scope.$broadcast = function() { }; |
| 926 | var cliente = { | 910 | var cliente = { |
| 927 | COD: undefined, | 911 | COD: undefined, |
| 928 | CUIT: undefined, | 912 | CUIT: undefined, |
| 929 | NOM: undefined | 913 | NOM: undefined |
| 930 | }; | 914 | }; |
| 931 | 915 | ||
| 932 | //act | 916 | //act |
| 933 | spyOn(uibModal, 'open').and.returnValue(promesaRespuesta); | 917 | spyOn(uibModal, 'open').and.returnValue(promesaRespuesta); |
| 934 | spyOn(scope, '$broadcast'); | 918 | spyOn(scope, '$broadcast'); |
| 935 | scope.abrirModalDomicilios({ }); | 919 | scope.abrirModalDomicilios({ }); |
| 936 | 920 | ||
| 937 | //assert | 921 | //assert |
| 938 | promesaRespuesta.result.then(function() { | 922 | promesaRespuesta.result.then(function() { |
| 939 | expect(scope.notaPedido.domicilio).toEqual(respuesta); | 923 | expect(scope.notaPedido.domicilio).toEqual(respuesta); |
| 940 | expect(scope.notaPedido.cliente).toEqual(cliente); | 924 | expect(scope.notaPedido.cliente).toEqual(cliente); |
| 941 | expect(scope.$broadcast).toHaveBeenCalled(); | 925 | expect(scope.$broadcast).toHaveBeenCalled(); |
| 942 | done(); | 926 | done(); |
| 943 | }); | 927 | }); |
| 944 | }); | 928 | }); |
| 945 | 929 | ||
| 946 | it('función getTotal devulve correctamente', function() { | 930 | it('función getTotal devulve correctamente', function() { |
| 947 | 931 | ||
| 948 | //arrange | 932 | //arrange |
| 949 | var scope = { | 933 | var scope = { |
| 950 | $watch: function() { }, | 934 | $watch: function() { }, |
| 951 | $broadcast: function() { } | 935 | $broadcast: function() { } |
| 952 | }; | 936 | }; |
| 953 | 937 | ||
| 954 | $controler('notaPedidoCtrl', { | 938 | $controler('notaPedidoCtrl', { |
| 955 | $scope: scope, | 939 | $scope: scope, |
| 956 | $uibModal: {}, | 940 | $uibModal: {}, |
| 957 | $location: {}, | 941 | $location: {}, |
| 958 | $filter: filter, | 942 | $filter: filter, |
| 959 | $timeout: timeout, | 943 | $timeout: timeout, |
| 960 | crearNotaPedidoService: { | 944 | crearNotaPedidoService: { |
| 961 | getNumeroNotaPedido: function() { | 945 | getNumeroNotaPedido: function() { |
| 962 | return { | 946 | return { |
| 963 | then: function() { } | 947 | then: function() { } |
| 964 | }; | 948 | }; |
| 965 | }, | 949 | }, |
| 966 | getBotonera: function() { }, | 950 | getBotonera: function() { }, |
| 967 | getCotizacionByIdMoneda: function() { | 951 | getCotizacionByIdMoneda: function() { |
| 968 | return { | 952 | return { |
| 969 | then: function() { } | 953 | then: function() { } |
| 970 | }; | 954 | }; |
| 971 | } | 955 | } |
| 972 | }, | 956 | }, |
| 973 | focaBotoneraLateralService: {}, | 957 | focaBotoneraLateralService: {}, |
| 974 | focaModalService: {}, | 958 | focaModalService: {}, |
| 975 | notaPedidoBusinessService: {}, | 959 | notaPedidoBusinessService: {}, |
| 976 | $rootScope: { | 960 | $rootScope: { |
| 977 | $on: function() { } | 961 | $on: function() { } |
| 978 | }, | 962 | }, |
| 979 | focaSeguimientoService: {}, | 963 | focaSeguimientoService: {}, |
| 980 | APP: {}, | 964 | APP: {}, |
| 981 | focaLoginService: {}, | 965 | focaLoginService: {}, |
| 982 | $localStorage: {} | 966 | $localStorage: {} |
| 983 | }); | 967 | }); |
| 984 | scope.idLista = true; | 968 | scope.idLista = true; |
| 985 | scope.notaPedido = { | 969 | scope.notaPedido = { |
| 986 | vendedor: { NUM: true } | 970 | vendedor: { NUM: true } |
| 987 | }; | 971 | }; |
| 988 | 972 | ||
| 989 | //act | 973 | //act |
| 990 | scope.notaPedido.articulosNotaPedido = [{ precio: 2, cantidad: 1}]; | 974 | scope.notaPedido.articulosNotaPedido = [{ precio: 2, cantidad: 1}]; |
| 991 | var esperado = 2; | 975 | var esperado = 2; |
| 992 | var resultado = scope.getTotal(); | 976 | var resultado = scope.getTotal(); |
| 993 | 977 | ||
| 994 | //assert | 978 | //assert |
| 995 | expect(resultado).toEqual(esperado); | 979 | expect(resultado).toEqual(esperado); |
| 996 | }); | 980 | }); |
| 997 | 981 | ||
| 998 | it('función getSubTotal devulve correctamente', function() { | 982 | it('función getSubTotal devulve correctamente', function() { |
| 999 | 983 | ||
| 1000 | //arrange | 984 | //arrange |
| 1001 | var scope = { | 985 | var scope = { |
| 1002 | $watch: function() { }, | 986 | $watch: function() { }, |
| 1003 | $broadcast: function() { } | 987 | $broadcast: function() { } |
| 1004 | }; | 988 | }; |
| 1005 | 989 | ||
| 1006 | $controler('notaPedidoCtrl', { | 990 | $controler('notaPedidoCtrl', { |
| 1007 | $scope: scope, | 991 | $scope: scope, |
| 1008 | $uibModal: {}, | 992 | $uibModal: {}, |
| 1009 | $location: {}, | 993 | $location: {}, |
| 1010 | $filter: filter, | 994 | $filter: filter, |
| 1011 | $timeout: timeout, | 995 | $timeout: timeout, |
| 1012 | crearNotaPedidoService: { | 996 | crearNotaPedidoService: { |
| 1013 | getNumeroNotaPedido: function() { | 997 | getNumeroNotaPedido: function() { |
| 1014 | return { | 998 | return { |
| 1015 | then: function() { } | 999 | then: function() { } |
| 1016 | }; | 1000 | }; |
| 1017 | }, | 1001 | }, |
| 1018 | getBotonera: function() { }, | 1002 | getBotonera: function() { }, |
| 1019 | getCotizacionByIdMoneda: function() { | 1003 | getCotizacionByIdMoneda: function() { |
| 1020 | return { | 1004 | return { |
| 1021 | then: function() { } | 1005 | then: function() { } |
| 1022 | }; | 1006 | }; |
| 1023 | } | 1007 | } |
| 1024 | }, | 1008 | }, |
| 1025 | focaBotoneraLateralService: {}, | 1009 | focaBotoneraLateralService: {}, |
| 1026 | focaModalService: {}, | 1010 | focaModalService: {}, |
| 1027 | notaPedidoBusinessService: {}, | 1011 | notaPedidoBusinessService: {}, |
| 1028 | $rootScope: { | 1012 | $rootScope: { |
| 1029 | $on: function() { } | 1013 | $on: function() { } |
| 1030 | }, | 1014 | }, |
| 1031 | focaSeguimientoService: {}, | 1015 | focaSeguimientoService: {}, |
| 1032 | APP: {}, | 1016 | APP: {}, |
| 1033 | focaLoginService: {}, | 1017 | focaLoginService: {}, |
| 1034 | $localStorage: {} | 1018 | $localStorage: {} |
| 1035 | }); | 1019 | }); |
| 1036 | scope.idLista = true; | 1020 | scope.idLista = true; |
| 1037 | scope.notaPedido = { | 1021 | scope.notaPedido = { |
| 1038 | vendedor: { NUM: true } | 1022 | vendedor: { NUM: true } |
| 1039 | }; | 1023 | }; |
| 1040 | 1024 | ||
| 1041 | //act | 1025 | //act |
| 1042 | scope.articuloACargar = { precio: 2, cantidad: 1}; | 1026 | scope.articuloACargar = { precio: 2, cantidad: 1}; |
| 1043 | var esperado = 2; | 1027 | var esperado = 2; |
| 1044 | var resultado = scope.getSubTotal(); | 1028 | var resultado = scope.getSubTotal(); |
| 1045 | 1029 | ||
| 1046 | //assert | 1030 | //assert |
| 1047 | expect(resultado).toEqual(esperado); | 1031 | expect(resultado).toEqual(esperado); |
| 1048 | }); | 1032 | }); |
| 1049 | 1033 | ||
| 1050 | it('función seleccionarPreciosYCondiciones abre modal', function() { | 1034 | it('función seleccionarPreciosYCondiciones abre modal', function() { |
| 1051 | 1035 | ||
| 1052 | //arrange | 1036 | //arrange |
| 1053 | var scope = { | 1037 | var scope = { |
| 1054 | $watch: function() { }, | 1038 | $watch: function() { }, |
| 1055 | $broadcast: function() { } | 1039 | $broadcast: function() { } |
| 1056 | }; | 1040 | }; |
| 1057 | var uibModal = { | 1041 | var uibModal = { |
| 1058 | open: function() { } | 1042 | open: function() { } |
| 1059 | }; | 1043 | }; |
| 1060 | 1044 | ||
| 1061 | $controler('notaPedidoCtrl', { | 1045 | $controler('notaPedidoCtrl', { |
| 1062 | $scope: scope, | 1046 | $scope: scope, |
| 1063 | $uibModal: uibModal, | 1047 | $uibModal: uibModal, |
| 1064 | $location: {}, | 1048 | $location: {}, |
| 1065 | $filter: filter, | 1049 | $filter: filter, |
| 1066 | $timeout: timeout, | 1050 | $timeout: timeout, |
| 1067 | crearNotaPedidoService: { | 1051 | crearNotaPedidoService: { |
| 1068 | getNumeroNotaPedido: function() { | 1052 | getNumeroNotaPedido: function() { |
| 1069 | return { | 1053 | return { |
| 1070 | then: function() { } | 1054 | then: function() { } |
| 1071 | }; | 1055 | }; |
| 1072 | }, | 1056 | }, |
| 1073 | getBotonera: function() { }, | 1057 | getBotonera: function() { }, |
| 1074 | getCotizacionByIdMoneda: function() { | 1058 | getCotizacionByIdMoneda: function() { |
| 1075 | return { | 1059 | return { |
| 1076 | then: function() { } | 1060 | then: function() { } |
| 1077 | }; | 1061 | }; |
| 1078 | } | 1062 | } |
| 1079 | }, | 1063 | }, |
| 1080 | focaBotoneraLateralService: {}, | 1064 | focaBotoneraLateralService: {}, |
| 1081 | focaModalService: {}, | 1065 | focaModalService: {}, |
| 1082 | notaPedidoBusinessService: {}, | 1066 | notaPedidoBusinessService: {}, |
| 1083 | $rootScope: { | 1067 | $rootScope: { |
| 1084 | $on: function() { } | 1068 | $on: function() { } |
| 1085 | }, | 1069 | }, |
| 1086 | focaSeguimientoService: {}, | 1070 | focaSeguimientoService: {}, |
| 1087 | APP: {}, | 1071 | APP: {}, |
| 1088 | focaLoginService: {}, | 1072 | focaLoginService: {}, |
| 1089 | $localStorage: {} | 1073 | $localStorage: {} |
| 1090 | }); | 1074 | }); |
| 1091 | 1075 | ||
| 1092 | scope.notaPedido = {}; | 1076 | scope.notaPedido = {}; |
| 1093 | 1077 | ||
| 1094 | var respuesta = { result: {then: function() { } } }; | 1078 | var respuesta = { result: {then: function() { } } }; |
| 1095 | 1079 | ||
| 1096 | //act | 1080 | //act |
| 1097 | spyOn(uibModal, 'open').and.returnValue(respuesta); | 1081 | spyOn(uibModal, 'open').and.returnValue(respuesta); |
| 1098 | scope.seleccionarPreciosYCondiciones(); | 1082 | scope.seleccionarPreciosYCondiciones(); |
| 1099 | 1083 | ||
| 1100 | //assert | 1084 | //assert |
| 1101 | expect(uibModal.open).toHaveBeenCalled(); | 1085 | expect(uibModal.open).toHaveBeenCalled(); |
| 1102 | }); | 1086 | }); |
| 1103 | 1087 | ||
| 1104 | it('función seleccionarPreciosYCondiciones setea articulos y cabecera', function(done) { | 1088 | it('función seleccionarPreciosYCondiciones setea articulos y cabecera', function(done) { |
| 1105 | 1089 | ||
| 1106 | //arrange | 1090 | //arrange |
| 1107 | var scope = { | 1091 | var scope = { |
| 1108 | $watch: function() { }, | 1092 | $watch: function() { }, |
| 1109 | $broadcast: function() { } | 1093 | $broadcast: function() { } |
| 1110 | }; | 1094 | }; |
| 1111 | var uibModal = { | 1095 | var uibModal = { |
| 1112 | open: function() { } | 1096 | open: function() { } |
| 1113 | }; | 1097 | }; |
| 1114 | 1098 | ||
| 1115 | $controler('notaPedidoCtrl', { | 1099 | $controler('notaPedidoCtrl', { |
| 1116 | $scope: scope, | 1100 | $scope: scope, |
| 1117 | $uibModal: uibModal, | 1101 | $uibModal: uibModal, |
| 1118 | $location: {}, | 1102 | $location: {}, |
| 1119 | $filter: filter, | 1103 | $filter: filter, |
| 1120 | $timeout: timeout, | 1104 | $timeout: timeout, |
| 1121 | crearNotaPedidoService: { | 1105 | crearNotaPedidoService: { |
| 1122 | getNumeroNotaPedido: function() { | 1106 | getNumeroNotaPedido: function() { |
| 1123 | return { | 1107 | return { |
| 1124 | then: function() { } | 1108 | then: function() { } |
| 1125 | }; | 1109 | }; |
| 1126 | }, | 1110 | }, |
| 1127 | getBotonera: function() { }, | 1111 | getBotonera: function() { }, |
| 1128 | getCotizacionByIdMoneda: function() { | 1112 | getCotizacionByIdMoneda: function() { |
| 1129 | return { | 1113 | return { |
| 1130 | then: function() { } | 1114 | then: function() { } |
| 1131 | }; | 1115 | }; |
| 1132 | } | 1116 | } |
| 1133 | }, | 1117 | }, |
| 1134 | focaBotoneraLateralService: {}, | 1118 | focaBotoneraLateralService: {}, |
| 1135 | focaModalService: {}, | 1119 | focaModalService: {}, |
| 1136 | notaPedidoBusinessService: {}, | 1120 | notaPedidoBusinessService: {}, |
| 1137 | $rootScope: { | 1121 | $rootScope: { |
| 1138 | $on: function() { } | 1122 | $on: function() { } |
| 1139 | }, | 1123 | }, |
| 1140 | focaSeguimientoService: {}, | 1124 | focaSeguimientoService: {}, |
| 1141 | APP: {}, | 1125 | APP: {}, |
| 1142 | focaLoginService: {}, | 1126 | focaLoginService: {}, |
| 1143 | $localStorage: {} | 1127 | $localStorage: {} |
| 1144 | }); | 1128 | }); |
| 1145 | scope.idLista = true; | 1129 | scope.idLista = true; |
| 1146 | scope.notaPedido = { | 1130 | scope.notaPedido = { |
| 1147 | vendedor: { NUM: true } | 1131 | vendedor: { NUM: true } |
| 1148 | }; | 1132 | }; |
| 1149 | var respuesta = { plazoPago: { } }; | 1133 | var respuesta = { plazoPago: { } }; |
| 1150 | var promesaRespuesta = { result: Promise.resolve(respuesta) }; | 1134 | var promesaRespuesta = { result: Promise.resolve(respuesta) }; |
| 1151 | scope.$broadcast = function() { }; | 1135 | scope.$broadcast = function() { }; |
| 1152 | 1136 | ||
| 1153 | //act | 1137 | //act |
| 1154 | spyOn(uibModal, 'open').and.returnValue(promesaRespuesta); | 1138 | spyOn(uibModal, 'open').and.returnValue(promesaRespuesta); |
| 1155 | spyOn(scope, '$broadcast'); | 1139 | spyOn(scope, '$broadcast'); |
| 1156 | scope.seleccionarPreciosYCondiciones(); | 1140 | scope.seleccionarPreciosYCondiciones(); |
| 1157 | 1141 | ||
| 1158 | //assert | 1142 | //assert |
| 1159 | promesaRespuesta.result.then(function() { | 1143 | promesaRespuesta.result.then(function() { |
| 1160 | expect(scope.notaPedido.articulosNotaPedido.length).toEqual(0); | 1144 | expect(scope.notaPedido.articulosNotaPedido.length).toEqual(0); |
| 1161 | expect(scope.$broadcast).toHaveBeenCalled(); | 1145 | expect(scope.$broadcast).toHaveBeenCalled(); |
| 1162 | done(); | 1146 | done(); |
| 1163 | }); | 1147 | }); |
| 1164 | }); | 1148 | }); |
| 1165 | 1149 | ||
| 1166 | it('función seleccionarFlete abre modal', function() { | ||
| 1167 | |||
| 1168 | //arrange | ||
| 1169 | var scope = { | ||
| 1170 | $watch: function() { }, | ||
| 1171 | $broadcast: function() { } | ||
| 1172 | }; | ||
| 1173 | var uibModal = { | ||
| 1174 | open: function() { } | ||
| 1175 | }; | ||
| 1176 | |||
| 1177 | $controler('notaPedidoCtrl', { | ||
| 1178 | $scope: scope, | ||
| 1179 | $uibModal: uibModal, | ||
| 1180 | $location: {}, | ||
| 1181 | $filter: filter, | ||
| 1182 | $timeout: timeout, | ||
| 1183 | crearNotaPedidoService: { | ||
| 1184 | getNumeroNotaPedido: function() { | ||
| 1185 | return { | ||
| 1186 | then: function() { } | ||
| 1187 | }; | ||
| 1188 | }, | ||
| 1189 | getBotonera: function() { }, | ||
| 1190 | getCotizacionByIdMoneda: function() { | ||
| 1191 | return { | ||
| 1192 | then: function() { } | ||
| 1193 | }; | ||
| 1194 | } | ||
| 1195 | }, | ||
| 1196 | focaBotoneraLateralService: {}, | ||
| 1197 | focaModalService: {}, | ||
| 1198 | notaPedidoBusinessService: {}, | ||
| 1199 | $rootScope: { | ||
| 1200 | $on: function() { } | ||
| 1201 | }, | ||
| 1202 | focaSeguimientoService: {}, | ||
| 1203 | APP: {}, | ||
| 1204 | focaLoginService: {}, | ||
| 1205 | $localStorage: {} | ||
| 1206 | }); | ||
| 1207 | |||
| 1208 | scope.notaPedido = {}; | ||
| 1209 | |||
| 1210 | var respuesta = { result: {then: function() { } } }; | ||
| 1211 | |||
| 1212 | //act | ||
| 1213 | spyOn(uibModal, 'open').and.returnValue(respuesta); | ||
| 1214 | scope.seleccionarFlete(); | ||
| 1215 | |||
| 1216 | //assert | ||
| 1217 | expect(uibModal.open).toHaveBeenCalled(); | ||
| 1218 | }); | ||
| 1219 | |||
| 1220 | it('función seleccionarFlete setea flete y cabecera', function(done) { | ||
| 1221 | |||
| 1222 | //arrange | ||
| 1223 | var scope = { | ||
| 1224 | $watch: function() { }, | ||
| 1225 | $broadcast: function() { } | ||
| 1226 | }; | ||
| 1227 | var uibModal = { | ||
| 1228 | open: function() { } | ||
| 1229 | }; | ||
| 1230 | |||
| 1231 | $controler('notaPedidoCtrl', { | ||
| 1232 | $scope: scope, | ||
| 1233 | $uibModal: uibModal, | ||
| 1234 | $location: {}, | ||
| 1235 | $filter: filter, | ||
| 1236 | $timeout: timeout, | ||
| 1237 | crearNotaPedidoService: { | ||
| 1238 | getNumeroNotaPedido: function() { | ||
| 1239 | return { | ||
| 1240 | then: function() { } | ||
| 1241 | }; | ||
| 1242 | }, | ||
| 1243 | getBotonera: function() { }, | ||
| 1244 | getCotizacionByIdMoneda: function() { | ||
| 1245 | return { | ||
| 1246 | then: function() { } | ||
| 1247 | }; | ||
| 1248 | } | ||
| 1249 | }, | ||
| 1250 | focaBotoneraLateralService: {}, | ||
| 1251 | focaModalService: {}, | ||
| 1252 | notaPedidoBusinessService: {}, | ||
| 1253 | $rootScope: { | ||
| 1254 | $on: function() { } | ||
| 1255 | }, | ||
| 1256 | focaSeguimientoService: {}, | ||
| 1257 | APP: {}, | ||
| 1258 | focaLoginService: {}, | ||
| 1259 | $localStorage: {} | ||
| 1260 | }); | ||
| 1261 | scope.idLista = true; | ||
| 1262 | scope.notaPedido = { | ||
| 1263 | vendedor: { NUM: true } | ||
| 1264 | }; | ||
| 1265 | var respuesta = { flete: 1, FOB: 2, bomba: 3, kilometros: 4 }; | ||
| 1266 | var promesaRespuesta = { result: Promise.resolve(respuesta) }; | ||
| 1267 | scope.$broadcast = function() { }; | ||
| 1268 | |||
| 1269 | //act | ||
| 1270 | spyOn(uibModal, 'open').and.returnValue(promesaRespuesta); | ||
| 1271 | spyOn(scope, '$broadcast'); | ||
| 1272 | scope.seleccionarFlete(); | ||
| 1273 | |||
| 1274 | //assert | ||
| 1275 | |||
| 1276 | promesaRespuesta.result.then(function() { | ||
| 1277 | expect(scope.notaPedido.flete).toEqual(respuesta.flete); | ||
| 1278 | expect(scope.notaPedido.fob).toEqual(respuesta.FOB); | ||
| 1279 | expect(scope.notaPedido.bomba).toEqual(respuesta.bomba); | ||
| 1280 | expect(scope.notaPedido.kilometros).toEqual(respuesta.kilometros); | ||
| 1281 | expect(scope.$broadcast).toHaveBeenCalled(); | ||
| 1282 | done(); | ||
| 1283 | }); | ||
| 1284 | }); | ||
| 1285 | |||
| 1286 | it('función seleccionarMoneda abre modal', function() { | 1150 | it('función seleccionarMoneda abre modal', function() { |
| 1287 | //arrange | 1151 | //arrange |
| 1288 | var scope = { | 1152 | var scope = { |
| 1289 | $watch: function() { }, | 1153 | $watch: function() { }, |
| 1290 | $broadcast: function() { } | 1154 | $broadcast: function() { } |
| 1291 | }; | 1155 | }; |
| 1292 | var focaModalService = { | 1156 | var focaModalService = { |
| 1293 | modal: function() { } | 1157 | modal: function() { } |
| 1294 | }; | 1158 | }; |
| 1295 | 1159 | ||
| 1296 | $controler('notaPedidoCtrl', { | 1160 | $controler('notaPedidoCtrl', { |
| 1297 | $scope: scope, | 1161 | $scope: scope, |
| 1298 | $uibModal: {}, | 1162 | $uibModal: {}, |
| 1299 | $location: {}, | 1163 | $location: {}, |
| 1300 | $filter: filter, | 1164 | $filter: filter, |
| 1301 | $timeout: timeout, | 1165 | $timeout: timeout, |
| 1302 | crearNotaPedidoService: { | 1166 | crearNotaPedidoService: { |
| 1303 | getNumeroNotaPedido: function() { | 1167 | getNumeroNotaPedido: function() { |
| 1304 | return { | 1168 | return { |
| 1305 | then: function() { } | 1169 | then: function() { } |
| 1306 | }; | 1170 | }; |
| 1307 | }, | 1171 | }, |
| 1308 | getBotonera: function() { }, | 1172 | getBotonera: function() { }, |
| 1309 | getCotizacionByIdMoneda: function() { | 1173 | getCotizacionByIdMoneda: function() { |
| 1310 | return { | 1174 | return { |
| 1311 | then: function() { } | 1175 | then: function() { } |
| 1312 | }; | 1176 | }; |
| 1313 | } | 1177 | } |
| 1314 | }, | 1178 | }, |
| 1315 | focaBotoneraLateralService: {}, | 1179 | focaBotoneraLateralService: {}, |
| 1316 | focaModalService: focaModalService, | 1180 | focaModalService: focaModalService, |
| 1317 | notaPedidoBusinessService: {}, | 1181 | notaPedidoBusinessService: {}, |
| 1318 | $rootScope: { | 1182 | $rootScope: { |
| 1319 | $on: function() { } | 1183 | $on: function() { } |
| 1320 | }, | 1184 | }, |
| 1321 | focaSeguimientoService: {}, | 1185 | focaSeguimientoService: {}, |
| 1322 | APP: {}, | 1186 | APP: {}, |
| 1323 | focaLoginService: {}, | 1187 | focaLoginService: {}, |
| 1324 | $localStorage: {} | 1188 | $localStorage: {} |
| 1325 | }); | 1189 | }); |
| 1326 | scope.notaPedido = {}; | 1190 | scope.notaPedido = {}; |
| 1327 | 1191 | ||
| 1328 | var respuesta = { then: function() { } }; | 1192 | var respuesta = { then: function() { } }; |
| 1329 | 1193 | ||
| 1330 | //act | 1194 | //act |
| 1331 | spyOn(focaModalService, 'modal').and.returnValue(respuesta); | 1195 | spyOn(focaModalService, 'modal').and.returnValue(respuesta); |
| 1332 | scope.seleccionarMoneda(); | 1196 | scope.seleccionarMoneda(); |
| 1333 | 1197 | ||
| 1334 | //assert | 1198 | //assert |
| 1335 | expect(focaModalService.modal).toHaveBeenCalled(); | 1199 | expect(focaModalService.modal).toHaveBeenCalled(); |
| 1336 | }); | 1200 | }); |
| 1337 | 1201 | ||
| 1338 | it('función seleccionarMoneda llama Modal Cotizacion', function(done) { | 1202 | it('función seleccionarMoneda llama Modal Cotizacion', function(done) { |
| 1339 | //arrange | 1203 | //arrange |
| 1340 | var scope = { | 1204 | var scope = { |
| 1341 | $watch: function() { }, | 1205 | $watch: function() { }, |
| 1342 | $broadcast: function() { } | 1206 | $broadcast: function() { } |
| 1343 | }; | 1207 | }; |
| 1344 | var focaModalService = { | 1208 | var focaModalService = { |
| 1345 | modal: function() { } | 1209 | modal: function() { } |
| 1346 | }; | 1210 | }; |
| 1347 | 1211 | ||
| 1348 | $controler('notaPedidoCtrl', { | 1212 | $controler('notaPedidoCtrl', { |
| 1349 | $scope: scope, | 1213 | $scope: scope, |
| 1350 | $uibModal: {}, | 1214 | $uibModal: {}, |
| 1351 | $location: {}, | 1215 | $location: {}, |
| 1352 | $filter: filter, | 1216 | $filter: filter, |
| 1353 | $timeout: timeout, | 1217 | $timeout: timeout, |
| 1354 | crearNotaPedidoService: { | 1218 | crearNotaPedidoService: { |
| 1355 | getNumeroNotaPedido: function() { | 1219 | getNumeroNotaPedido: function() { |
| 1356 | return { | 1220 | return { |
| 1357 | then: function() { } | 1221 | then: function() { } |
| 1358 | }; | 1222 | }; |
| 1359 | }, | 1223 | }, |
| 1360 | getBotonera: function() { }, | 1224 | getBotonera: function() { }, |
| 1361 | getCotizacionByIdMoneda: function() { | 1225 | getCotizacionByIdMoneda: function() { |
| 1362 | return { | 1226 | return { |
| 1363 | then: function() { } | 1227 | then: function() { } |
| 1364 | }; | 1228 | }; |
| 1365 | } | 1229 | } |
| 1366 | }, | 1230 | }, |
| 1367 | focaBotoneraLateralService: {}, | 1231 | focaBotoneraLateralService: {}, |
| 1368 | focaModalService: focaModalService, | 1232 | focaModalService: focaModalService, |
| 1369 | notaPedidoBusinessService: {}, | 1233 | notaPedidoBusinessService: {}, |
| 1370 | $rootScope: { | 1234 | $rootScope: { |
| 1371 | $on: function() { } | 1235 | $on: function() { } |
| 1372 | }, | 1236 | }, |
| 1373 | focaSeguimientoService: {}, | 1237 | focaSeguimientoService: {}, |
| 1374 | APP: {}, | 1238 | APP: {}, |
| 1375 | focaLoginService: {}, | 1239 | focaLoginService: {}, |
| 1376 | $localStorage: {} | 1240 | $localStorage: {} |
| 1377 | }); | 1241 | }); |
| 1378 | 1242 | ||
| 1379 | scope.notaPedido = {}; | 1243 | scope.notaPedido = {}; |
| 1380 | var respuesta = 'test'; | 1244 | var respuesta = 'test'; |
| 1381 | var promesaRespuesta = Promise.resolve(respuesta); | 1245 | var promesaRespuesta = Promise.resolve(respuesta); |
| 1382 | 1246 | ||
| 1383 | //act | 1247 | //act |
| 1384 | spyOn(focaModalService, 'modal').and.returnValue(promesaRespuesta); | 1248 | spyOn(focaModalService, 'modal').and.returnValue(promesaRespuesta); |
| 1385 | spyOn(scope, 'abrirModalCotizacion'); | 1249 | spyOn(scope, 'abrirModalCotizacion'); |
| 1386 | scope.seleccionarMoneda(); | 1250 | scope.seleccionarMoneda(); |
| 1387 | 1251 | ||
| 1388 | //assert | 1252 | //assert |
| 1389 | promesaRespuesta.then(function() { | 1253 | promesaRespuesta.then(function() { |
| 1390 | expect(scope.abrirModalCotizacion).toHaveBeenCalledWith('test'); | 1254 | expect(scope.abrirModalCotizacion).toHaveBeenCalledWith('test'); |
| 1391 | done(); | 1255 | done(); |
| 1392 | }); | 1256 | }); |
| 1393 | }); | 1257 | }); |
| 1394 | 1258 | ||
| 1395 | it('función seleccionarObservaciones llama a prompt', function() { | 1259 | it('función seleccionarObservaciones llama a prompt', function() { |
| 1396 | 1260 | ||
| 1397 | //arrange | 1261 | //arrange |
| 1398 | var scope = { | 1262 | var scope = { |
| 1399 | $watch: function() { }, | 1263 | $watch: function() { }, |
| 1400 | $broadcast: function() { } | 1264 | $broadcast: function() { } |
| 1401 | }; | 1265 | }; |
| 1402 | var focaModalService = { | 1266 | var focaModalService = { |
| 1403 | prompt: function() { } | 1267 | prompt: function() { } |
| 1404 | }; | 1268 | }; |
| 1405 | 1269 | ||
| 1406 | $controler('notaPedidoCtrl', { | 1270 | $controler('notaPedidoCtrl', { |
| 1407 | $scope: scope, | 1271 | $scope: scope, |
| 1408 | $uibModal: {}, | 1272 | $uibModal: {}, |
| 1409 | $location: {}, | 1273 | $location: {}, |
| 1410 | $filter: filter, | 1274 | $filter: filter, |
| 1411 | $timeout: timeout, | 1275 | $timeout: timeout, |
| 1412 | crearNotaPedidoService: { | 1276 | crearNotaPedidoService: { |
| 1413 | getNumeroNotaPedido: function() { | 1277 | getNumeroNotaPedido: function() { |
| 1414 | return { | 1278 | return { |
| 1415 | then: function() { } | 1279 | then: function() { } |
| 1416 | }; | 1280 | }; |
| 1417 | }, | 1281 | }, |
| 1418 | getBotonera: function() { }, | 1282 | getBotonera: function() { }, |
| 1419 | getCotizacionByIdMoneda: function() { | 1283 | getCotizacionByIdMoneda: function() { |
| 1420 | return { | 1284 | return { |
| 1421 | then: function() { } | 1285 | then: function() { } |
| 1422 | }; | 1286 | }; |
| 1423 | } | 1287 | } |
| 1424 | }, | 1288 | }, |
| 1425 | focaBotoneraLateralService: {}, | 1289 | focaBotoneraLateralService: {}, |
| 1426 | focaModalService: focaModalService, | 1290 | focaModalService: focaModalService, |
| 1427 | notaPedidoBusinessService: {}, | 1291 | notaPedidoBusinessService: {}, |
| 1428 | $rootScope: { | 1292 | $rootScope: { |
| 1429 | $on: function() { } | 1293 | $on: function() { } |
| 1430 | }, | 1294 | }, |
| 1431 | focaSeguimientoService: {}, | 1295 | focaSeguimientoService: {}, |
| 1432 | APP: {}, | 1296 | APP: {}, |
| 1433 | focaLoginService: {}, | 1297 | focaLoginService: {}, |
| 1434 | $localStorage: {} | 1298 | $localStorage: {} |
| 1435 | }); | 1299 | }); |
| 1436 | var respuesta = { then: function() { } }; | 1300 | var respuesta = { then: function() { } }; |
| 1437 | scope.notaPedido = {}; | 1301 | scope.notaPedido = {}; |
| 1438 | 1302 | ||
| 1439 | //act | 1303 | //act |
| 1440 | spyOn(focaModalService, 'prompt').and.returnValue(respuesta); | 1304 | spyOn(focaModalService, 'prompt').and.returnValue(respuesta); |
| 1441 | scope.seleccionarObservaciones(); | 1305 | scope.seleccionarObservaciones(); |
| 1442 | 1306 | ||
| 1443 | //assert | 1307 | //assert |
| 1444 | expect(focaModalService.prompt).toHaveBeenCalled(); | 1308 | expect(focaModalService.prompt).toHaveBeenCalled(); |
| 1445 | }); | 1309 | }); |
| 1446 | 1310 | ||
| 1447 | it('función seleccionarObservaciones setea observaciones', function(done) { | 1311 | it('función seleccionarObservaciones setea observaciones', function(done) { |
| 1448 | 1312 | ||
| 1449 | //arrange | 1313 | //arrange |
| 1450 | var scope = { | 1314 | var scope = { |
| 1451 | $watch: function() { }, | 1315 | $watch: function() { }, |
| 1452 | $broadcast: function() { } | 1316 | $broadcast: function() { } |
| 1453 | }; | 1317 | }; |
| 1454 | var focaModalService = { | 1318 | var focaModalService = { |
| 1455 | prompt: function() { } | 1319 | prompt: function() { } |
| 1456 | }; | 1320 | }; |
| 1457 | 1321 | ||
| 1458 | $controler('notaPedidoCtrl', { | 1322 | $controler('notaPedidoCtrl', { |
| 1459 | $scope: scope, | 1323 | $scope: scope, |
| 1460 | $uibModal: {}, | 1324 | $uibModal: {}, |
| 1461 | $location: {}, | 1325 | $location: {}, |
| 1462 | $filter: filter, | 1326 | $filter: filter, |
| 1463 | $timeout: timeout, | 1327 | $timeout: timeout, |
| 1464 | crearNotaPedidoService: { | 1328 | crearNotaPedidoService: { |
| 1465 | getNumeroNotaPedido: function() { | 1329 | getNumeroNotaPedido: function() { |
| 1466 | return { | 1330 | return { |
| 1467 | then: function() { } | 1331 | then: function() { } |
| 1468 | }; | 1332 | }; |
| 1469 | }, | 1333 | }, |
| 1470 | getBotonera: function() { }, | 1334 | getBotonera: function() { }, |
| 1471 | getCotizacionByIdMoneda: function() { | 1335 | getCotizacionByIdMoneda: function() { |
| 1472 | return { | 1336 | return { |
| 1473 | then: function() { } | 1337 | then: function() { } |
| 1474 | }; | 1338 | }; |
| 1475 | } | 1339 | } |
| 1476 | }, | 1340 | }, |
| 1477 | focaBotoneraLateralService: {}, | 1341 | focaBotoneraLateralService: {}, |
| 1478 | focaModalService: focaModalService, | 1342 | focaModalService: focaModalService, |
| 1479 | notaPedidoBusinessService: {}, | 1343 | notaPedidoBusinessService: {}, |
| 1480 | $rootScope: { | 1344 | $rootScope: { |
| 1481 | $on: function() { } | 1345 | $on: function() { } |
| 1482 | }, | 1346 | }, |
| 1483 | focaSeguimientoService: {}, | 1347 | focaSeguimientoService: {}, |
| 1484 | APP: {}, | 1348 | APP: {}, |
| 1485 | focaLoginService: {}, | 1349 | focaLoginService: {}, |
| 1486 | $localStorage: {} | 1350 | $localStorage: {} |
| 1487 | }); | 1351 | }); |
| 1488 | var respuesta = 'unit test'; | 1352 | var respuesta = 'unit test'; |
| 1489 | var promesa = Promise.resolve(respuesta); | 1353 | var promesa = Promise.resolve(respuesta); |
| 1490 | scope.notaPedido = {}; | 1354 | scope.notaPedido = {}; |
| 1491 | 1355 | ||
| 1492 | //act | 1356 | //act |
| 1493 | spyOn(focaModalService, 'prompt').and.returnValue(promesa); | 1357 | spyOn(focaModalService, 'prompt').and.returnValue(promesa); |
| 1494 | scope.seleccionarObservaciones(); | 1358 | scope.seleccionarObservaciones(); |
| 1495 | 1359 | ||
| 1496 | //assert | 1360 | //assert |
| 1497 | promesa.then(function() { | 1361 | promesa.then(function() { |
| 1498 | expect(scope.notaPedido.observaciones).toEqual(respuesta); | 1362 | expect(scope.notaPedido.observaciones).toEqual(respuesta); |
| 1499 | done(); | 1363 | done(); |
| 1500 | }); | 1364 | }); |
| 1501 | }); | 1365 | }); |
| 1502 | 1366 | ||
| 1503 | it('función abrirModalCotizacion abre modal', function() { | 1367 | it('función abrirModalCotizacion abre modal', function() { |
| 1504 | 1368 | ||
| 1505 | //arrange | 1369 | //arrange |
| 1506 | var scope = { | 1370 | var scope = { |
| 1507 | $watch: function() { }, | 1371 | $watch: function() { }, |
| 1508 | $broadcast: function() { } | 1372 | $broadcast: function() { } |
| 1509 | }; | 1373 | }; |
| 1510 | var uibModal = { | 1374 | var uibModal = { |
| 1511 | open: function() { } | 1375 | open: function() { } |
| 1512 | }; | 1376 | }; |
| 1513 | 1377 | ||
| 1514 | $controler('notaPedidoCtrl', { | 1378 | $controler('notaPedidoCtrl', { |
| 1515 | $scope: scope, | 1379 | $scope: scope, |
| 1516 | $uibModal: uibModal, | 1380 | $uibModal: uibModal, |
| 1517 | $location: {}, | 1381 | $location: {}, |
| 1518 | $filter: filter, | 1382 | $filter: filter, |
| 1519 | $timeout: timeout, | 1383 | $timeout: timeout, |
| 1520 | crearNotaPedidoService: { | 1384 | crearNotaPedidoService: { |
| 1521 | getNumeroNotaPedido: function() { | 1385 | getNumeroNotaPedido: function() { |
| 1522 | return { | 1386 | return { |
| 1523 | then: function() { } | 1387 | then: function() { } |
| 1524 | }; | 1388 | }; |
| 1525 | }, | 1389 | }, |
| 1526 | getBotonera: function() { }, | 1390 | getBotonera: function() { }, |
| 1527 | getCotizacionByIdMoneda: function() { | 1391 | getCotizacionByIdMoneda: function() { |
| 1528 | return { | 1392 | return { |
| 1529 | then: function() { } | 1393 | then: function() { } |
| 1530 | }; | 1394 | }; |
| 1531 | } | 1395 | } |
| 1532 | }, | 1396 | }, |
| 1533 | focaBotoneraLateralService: {}, | 1397 | focaBotoneraLateralService: {}, |
| 1534 | focaModalService: {}, | 1398 | focaModalService: {}, |
| 1535 | notaPedidoBusinessService: {}, | 1399 | notaPedidoBusinessService: {}, |
| 1536 | $rootScope: { | 1400 | $rootScope: { |
| 1537 | $on: function() { } | 1401 | $on: function() { } |
| 1538 | }, | 1402 | }, |
| 1539 | focaSeguimientoService: {}, | 1403 | focaSeguimientoService: {}, |
| 1540 | APP: {}, | 1404 | APP: {}, |
| 1541 | focaLoginService: {}, | 1405 | focaLoginService: {}, |
| 1542 | $localStorage: {} | 1406 | $localStorage: {} |
| 1543 | }); | 1407 | }); |
| 1544 | 1408 | ||
| 1545 | scope.notaPedido = {}; | 1409 | scope.notaPedido = {}; |
| 1546 | 1410 | ||
| 1547 | var respuesta = { result: {then: function() { } } }; | 1411 | var respuesta = { result: {then: function() { } } }; |
| 1548 | 1412 | ||
| 1549 | //act | 1413 | //act |
| 1550 | spyOn(uibModal, 'open').and.returnValue(respuesta); | 1414 | spyOn(uibModal, 'open').and.returnValue(respuesta); |
| 1551 | scope.abrirModalCotizacion(); | 1415 | scope.abrirModalCotizacion(); |
| 1552 | 1416 | ||
| 1553 | //assert | 1417 | //assert |
| 1554 | expect(uibModal.open).toHaveBeenCalled(); | 1418 | expect(uibModal.open).toHaveBeenCalled(); |
| 1555 | }); | 1419 | }); |
| 1556 | 1420 | ||
| 1557 | it('función abrirModalCotizacion setea datos y cabecera', function(done) { | 1421 | it('función abrirModalCotizacion setea datos y cabecera', function(done) { |
| 1558 | //arrange | 1422 | //arrange |
| 1559 | var scope = { | 1423 | var scope = { |
| 1560 | $watch: function() { }, | 1424 | $watch: function() { }, |
| 1561 | $broadcast: function() { } | 1425 | $broadcast: function() { } |
| 1562 | }; | 1426 | }; |
| 1563 | var uibModal = { | 1427 | var uibModal = { |
| 1564 | open: function() { } | 1428 | open: function() { } |
| 1565 | }; | 1429 | }; |
| 1566 | 1430 | ||
| 1567 | $controler('notaPedidoCtrl', { | 1431 | $controler('notaPedidoCtrl', { |
| 1568 | $scope: scope, | 1432 | $scope: scope, |
| 1569 | $uibModal: uibModal, | 1433 | $uibModal: uibModal, |
| 1570 | $location: {}, | 1434 | $location: {}, |
| 1571 | $filter: filter, | 1435 | $filter: filter, |
| 1572 | $timeout: timeout, | 1436 | $timeout: timeout, |
| 1573 | crearNotaPedidoService: { | 1437 | crearNotaPedidoService: { |
| 1574 | getNumeroNotaPedido: function() { | 1438 | getNumeroNotaPedido: function() { |
| 1575 | return { | 1439 | return { |
| 1576 | then: function() { } | 1440 | then: function() { } |
| 1577 | }; | 1441 | }; |
| 1578 | }, | 1442 | }, |
| 1579 | getBotonera: function() { }, | 1443 | getBotonera: function() { }, |
| 1580 | getCotizacionByIdMoneda: function() { | 1444 | getCotizacionByIdMoneda: function() { |
| 1581 | return { | 1445 | return { |
| 1582 | then: function() { } | 1446 | then: function() { } |
| 1583 | }; | 1447 | }; |
| 1584 | } | 1448 | } |
| 1585 | }, | 1449 | }, |
| 1586 | focaBotoneraLateralService: {}, | 1450 | focaBotoneraLateralService: {}, |
| 1587 | focaModalService: {}, | 1451 | focaModalService: {}, |
| 1588 | notaPedidoBusinessService: {}, | 1452 | notaPedidoBusinessService: {}, |
| 1589 | $rootScope: { | 1453 | $rootScope: { |
| 1590 | $on: function() { } | 1454 | $on: function() { } |
| 1591 | }, | 1455 | }, |
| 1592 | focaSeguimientoService: {}, | 1456 | focaSeguimientoService: {}, |
| 1593 | APP: {}, | 1457 | APP: {}, |
| 1594 | focaLoginService: {}, | 1458 | focaLoginService: {}, |
| 1595 | $localStorage: {}, | 1459 | $localStorage: {}, |
| 1596 | articulosNotaPedido: [] | 1460 | articulosNotaPedido: [] |
| 1597 | }); | 1461 | }); |
| 1598 | 1462 | ||
| 1599 | scope.notaPedido = {}; | 1463 | scope.notaPedido = {}; |
| 1600 | scope.articulosTabla = []; | 1464 | scope.articulosTabla = []; |
| 1601 | scope.$broadcast = function() { }; | 1465 | scope.$broadcast = function() { }; |
| 1602 | var moneda = 'moneda'; | 1466 | var moneda = 'moneda'; |
| 1603 | var cotizacion = 'test'; | 1467 | var cotizacion = 'test'; |
| 1604 | var promesaRespuesta = { result: Promise.resolve(cotizacion) }; | 1468 | var promesaRespuesta = { result: Promise.resolve(cotizacion) }; |
| 1605 | 1469 | ||
| 1606 | //act | 1470 | //act |
| 1607 | spyOn(uibModal, 'open').and.returnValue(promesaRespuesta); | 1471 | spyOn(uibModal, 'open').and.returnValue(promesaRespuesta); |
| 1608 | spyOn(scope, '$broadcast'); | 1472 | spyOn(scope, '$broadcast'); |
| 1609 | scope.abrirModalCotizacion(moneda); | 1473 | scope.abrirModalCotizacion(moneda); |
| 1610 | 1474 | ||
| 1611 | //assert | 1475 | //assert |
| 1612 | promesaRespuesta.result.then(function() { | 1476 | promesaRespuesta.result.then(function() { |
| 1613 | 1477 | ||
| 1614 | expect(scope.$broadcast).toHaveBeenCalled(); | 1478 | expect(scope.$broadcast).toHaveBeenCalled(); |
| 1615 | expect(scope.notaPedido.cotizacion).toEqual(cotizacion); | 1479 | expect(scope.notaPedido.cotizacion).toEqual(cotizacion); |
| 1616 | done(); | 1480 | done(); |
| 1617 | }); | 1481 | }); |
| 1618 | }); | 1482 | }); |
| 1619 | 1483 | ||
| 1620 | it('función agregarATabla muestra alerta cuando a cargar undefined', function() { | 1484 | it('función agregarATabla muestra alerta cuando a cargar undefined', function() { |
| 1621 | 1485 | ||
| 1622 | //arrange | 1486 | //arrange |
| 1623 | var scope = { | 1487 | var scope = { |
| 1624 | $watch: function() { }, | 1488 | $watch: function() { }, |
| 1625 | $broadcast: function() { } | 1489 | $broadcast: function() { } |
| 1626 | }; | 1490 | }; |
| 1627 | var focaModalService = { | 1491 | var focaModalService = { |
| 1628 | alert: function() { } | 1492 | alert: function() { } |
| 1629 | }; | 1493 | }; |
| 1630 | 1494 | ||
| 1631 | $controler('notaPedidoCtrl', { | 1495 | $controler('notaPedidoCtrl', { |
| 1632 | $scope: scope, | 1496 | $scope: scope, |
| 1633 | $uibModal: {}, | 1497 | $uibModal: {}, |
| 1634 | $location: {}, | 1498 | $location: {}, |
| 1635 | $filter: filter, | 1499 | $filter: filter, |
| 1636 | $timeout: timeout, | 1500 | $timeout: timeout, |
| 1637 | crearNotaPedidoService: { | 1501 | crearNotaPedidoService: { |
| 1638 | getNumeroNotaPedido: function() { | 1502 | getNumeroNotaPedido: function() { |
| 1639 | return { | 1503 | return { |
| 1640 | then: function() { } | 1504 | then: function() { } |
| 1641 | }; | 1505 | }; |
| 1642 | }, | 1506 | }, |
| 1643 | getBotonera: function() { }, | 1507 | getBotonera: function() { }, |
| 1644 | getCotizacionByIdMoneda: function() { | 1508 | getCotizacionByIdMoneda: function() { |
| 1645 | return { | 1509 | return { |
| 1646 | then: function() { } | 1510 | then: function() { } |
| 1647 | }; | 1511 | }; |
| 1648 | } | 1512 | } |
| 1649 | }, | 1513 | }, |
| 1650 | focaBotoneraLateralService: {}, | 1514 | focaBotoneraLateralService: {}, |
| 1651 | focaModalService: focaModalService, | 1515 | focaModalService: focaModalService, |
| 1652 | notaPedidoBusinessService: {}, | 1516 | notaPedidoBusinessService: {}, |
| 1653 | $rootScope: { | 1517 | $rootScope: { |
| 1654 | $on: function() { } | 1518 | $on: function() { } |
| 1655 | }, | 1519 | }, |
| 1656 | focaSeguimientoService: {}, | 1520 | focaSeguimientoService: {}, |
| 1657 | APP: {}, | 1521 | APP: {}, |
| 1658 | focaLoginService: {}, | 1522 | focaLoginService: {}, |
| 1659 | $localStorage: {} | 1523 | $localStorage: {} |
| 1660 | }); | 1524 | }); |
| 1661 | scope.articuloACargar = {}; | 1525 | scope.articuloACargar = {}; |
| 1662 | 1526 | ||
| 1663 | //act | 1527 | //act |
| 1664 | spyOn(focaModalService, 'alert'); | 1528 | spyOn(focaModalService, 'alert'); |
| 1665 | scope.agregarATabla(13); | 1529 | scope.agregarATabla(13); |
| 1666 | 1530 | ||
| 1667 | //assert | 1531 | //assert |
| 1668 | expect(focaModalService.alert).toHaveBeenCalledWith('El valor debe ser al menos 1'); | 1532 | expect(focaModalService.alert).toHaveBeenCalledWith('El valor debe ser al menos 1'); |
| 1669 | }); | 1533 | }); |
| 1670 | 1534 | ||
| 1671 | it('función editarArticulo muestra alerta cuando a cargar es undefined', function() { | 1535 | it('función editarArticulo muestra alerta cuando a cargar es undefined', function() { |
| 1672 | 1536 | ||
| 1673 | //arrange | 1537 | //arrange |
| 1674 | var scope = { | 1538 | var scope = { |
| 1675 | $watch: function() { }, | 1539 | $watch: function() { }, |
| 1676 | $broadcast: function() { } | 1540 | $broadcast: function() { } |
| 1677 | }; | 1541 | }; |
| 1678 | var focaModalService = { | 1542 | var focaModalService = { |
| 1679 | alert: function() { } | 1543 | alert: function() { } |
| 1680 | }; | 1544 | }; |
| 1681 | 1545 | ||
| 1682 | $controler('notaPedidoCtrl', { | 1546 | $controler('notaPedidoCtrl', { |
| 1683 | $scope: scope, | 1547 | $scope: scope, |
| 1684 | $uibModal: {}, | 1548 | $uibModal: {}, |
| 1685 | $location: {}, | 1549 | $location: {}, |
| 1686 | $filter: filter, | 1550 | $filter: filter, |
| 1687 | $timeout: timeout, | 1551 | $timeout: timeout, |
| 1688 | crearNotaPedidoService: { | 1552 | crearNotaPedidoService: { |
| 1689 | getNumeroNotaPedido: function() { | 1553 | getNumeroNotaPedido: function() { |
| 1690 | return { | 1554 | return { |
| 1691 | then: function() { } | 1555 | then: function() { } |
| 1692 | }; | 1556 | }; |
| 1693 | }, | 1557 | }, |
| 1694 | getBotonera: function() { }, | 1558 | getBotonera: function() { }, |
| 1695 | getCotizacionByIdMoneda: function() { | 1559 | getCotizacionByIdMoneda: function() { |
| 1696 | return { | 1560 | return { |
| 1697 | then: function() { } | 1561 | then: function() { } |
| 1698 | }; | 1562 | }; |
| 1699 | } | 1563 | } |
| 1700 | }, | 1564 | }, |
| 1701 | focaBotoneraLateralService: {}, | 1565 | focaBotoneraLateralService: {}, |
| 1702 | focaModalService: focaModalService, | 1566 | focaModalService: focaModalService, |
| 1703 | notaPedidoBusinessService: {}, | 1567 | notaPedidoBusinessService: {}, |
| 1704 | $rootScope: { | 1568 | $rootScope: { |
| 1705 | $on: function() { } | 1569 | $on: function() { } |
| 1706 | }, | 1570 | }, |
| 1707 | focaSeguimientoService: {}, | 1571 | focaSeguimientoService: {}, |
| 1708 | APP: {}, | 1572 | APP: {}, |
| 1709 | focaLoginService: {}, | 1573 | focaLoginService: {}, |
| 1710 | $localStorage: {} | 1574 | $localStorage: {} |
| 1711 | }); | 1575 | }); |
| 1712 | scope.articuloACargar = {}; | 1576 | scope.articuloACargar = {}; |
| 1713 | 1577 | ||
| 1714 | //act | 1578 | //act |
| 1715 | spyOn(focaModalService, 'alert'); | 1579 | spyOn(focaModalService, 'alert'); |
| 1716 | scope.agregarATabla(13); | 1580 | scope.agregarATabla(13); |
| 1717 | 1581 | ||
| 1718 | //assert | 1582 | //assert |
| 1719 | expect(focaModalService.alert).toHaveBeenCalledWith('El valor debe ser al menos 1'); | 1583 | expect(focaModalService.alert).toHaveBeenCalledWith('El valor debe ser al menos 1'); |
| 1720 | }); | 1584 | }); |
| 1721 | 1585 | ||
| 1722 | it('función salir lleva a ruta correcta', function() { | 1586 | it('función salir lleva a ruta correcta', function() { |
| 1723 | 1587 | ||
| 1724 | inject(function($location) { | 1588 | inject(function($location) { |
| 1725 | 1589 | ||
| 1726 | //arrange | 1590 | //arrange |
| 1727 | var scope = { | 1591 | var scope = { |
| 1728 | $watch: function() { }, | 1592 | $watch: function() { }, |
| 1729 | $broadcast: function() { } | 1593 | $broadcast: function() { } |
| 1730 | }; | 1594 | }; |
| 1731 | 1595 | ||
| 1732 | $controler('notaPedidoCtrl', { | 1596 | $controler('notaPedidoCtrl', { |
| 1733 | $scope: scope, | 1597 | $scope: scope, |
| 1734 | $uibModal: {}, | 1598 | $uibModal: {}, |
| 1735 | $location: $location, | 1599 | $location: $location, |
| 1736 | $filter: filter, | 1600 | $filter: filter, |
spec/controllerSpecCrearPedido.js
| 1 | describe('Controladores módulo crear nota de pedido', function() { | 1 | describe('Controladores módulo crear nota de pedido', function() { |
| 2 | 2 | ||
| 3 | var $controler; | 3 | var $controler; |
| 4 | 4 | ||
| 5 | beforeEach(function() { | 5 | beforeEach(function() { |
| 6 | module('focaCrearNotaPedido'); | 6 | module('focaCrearNotaPedido'); |
| 7 | inject(function(_$controller_) { | 7 | inject(function(_$controller_) { |
| 8 | $controler = _$controller_; | 8 | $controler = _$controller_; |
| 9 | }); | 9 | }); |
| 10 | }); | 10 | }); |
| 11 | 11 | ||
| 12 | describe('Controlador notaPedidoCtrl crear nota de pedido', function() { | 12 | describe('Controlador notaPedidoCtrl crear nota de pedido', function() { |
| 13 | 13 | ||
| 14 | var filter = function() { | 14 | var filter = function() { |
| 15 | return function() { }; | 15 | return function() { }; |
| 16 | }; | 16 | }; |
| 17 | var timeout; | 17 | var timeout; |
| 18 | 18 | ||
| 19 | beforeEach(function() { | 19 | beforeEach(function() { |
| 20 | 20 | ||
| 21 | inject(function($timeout) { | 21 | inject(function($timeout) { |
| 22 | timeout = $timeout; | 22 | timeout = $timeout; |
| 23 | }); | 23 | }); |
| 24 | }); | 24 | }); |
| 25 | 25 | ||
| 26 | it('Existe el controlador notaPedidoCtrl', function() { | 26 | it('Existe el controlador notaPedidoCtrl', function() { |
| 27 | 27 | ||
| 28 | //act | 28 | //act |
| 29 | var controlador = $controler('notaPedidoCtrl', { | 29 | var controlador = $controler('notaPedidoCtrl', { |
| 30 | $scope: { | 30 | $scope: { |
| 31 | $watch: function() { }, | 31 | $watch: function() { }, |
| 32 | $broadcast: function() {} | 32 | $broadcast: function() {} |
| 33 | }, | 33 | }, |
| 34 | $uibModal: {}, | 34 | $uibModal: {}, |
| 35 | $location: {}, | 35 | $location: {}, |
| 36 | $filter: filter, | 36 | $filter: filter, |
| 37 | $timeout: timeout, | 37 | $timeout: timeout, |
| 38 | crearNotaPedidoService: { | 38 | crearNotaPedidoService: { |
| 39 | getNumeroNotaPedido: function() { | 39 | getNumeroNotaPedido: function() { |
| 40 | return { | 40 | return { |
| 41 | then: function() { } | 41 | then: function() { } |
| 42 | }; | 42 | }; |
| 43 | }, | 43 | }, |
| 44 | getBotonera: function() { }, | 44 | getBotonera: function() { }, |
| 45 | getCotizacionByIdMoneda: function() { | 45 | getCotizacionByIdMoneda: function() { |
| 46 | return { | 46 | return { |
| 47 | then: function() {} | 47 | then: function() {} |
| 48 | }; | 48 | }; |
| 49 | } | 49 | } |
| 50 | }, | 50 | }, |
| 51 | focaBotoneraLateralService: {}, | 51 | focaBotoneraLateralService: {}, |
| 52 | focaModalService: {}, | 52 | focaModalService: {}, |
| 53 | notaPedidoBusinessService: {}, | 53 | notaPedidoBusinessService: {}, |
| 54 | $rootScope: { | 54 | $rootScope: { |
| 55 | $on: function() { } | 55 | $on: function() { } |
| 56 | }, | 56 | }, |
| 57 | focaSeguimientoService: {}, | 57 | focaSeguimientoService: {}, |
| 58 | APP: {}, | 58 | APP: {}, |
| 59 | focaLoginService: {}, | 59 | focaLoginService: {}, |
| 60 | $localStorage: {} | 60 | $localStorage: {} |
| 61 | }); | 61 | }); |
| 62 | 62 | ||
| 63 | //expect | 63 | //expect |
| 64 | expect(typeof controlador).toEqual('object'); | 64 | expect(typeof controlador).toEqual('object'); |
| 65 | }); | 65 | }); |
| 66 | 66 | ||
| 67 | it('la funcion $scope.crearNotaPedido muestra alerta cuando vendedor es null', function() { | ||
| 68 | |||
| 69 | //arrange | ||
| 70 | var scope = { | ||
| 71 | $watch: function() { }, | ||
| 72 | $broadcast: function() {} | ||
| 73 | }; | ||
| 74 | var focaModalService = { | ||
| 75 | alert: function() { } | ||
| 76 | }; | ||
| 77 | |||
| 78 | $controler('notaPedidoCtrl', { | ||
| 79 | $scope: scope, | ||
| 80 | $uibModal: {}, | ||
| 81 | $location: {}, | ||
| 82 | $filter: filter, | ||
| 83 | $timeout: timeout, | ||
| 84 | crearNotaPedidoService: { | ||
| 85 | getNumeroNotaPedido: function() { | ||
| 86 | return { | ||
| 87 | then: function() { } | ||
| 88 | }; | ||
| 89 | }, | ||
| 90 | getBotonera: function() { }, | ||
| 91 | getCotizacionByIdMoneda: function() { | ||
| 92 | return { | ||
| 93 | then: function() {} | ||
| 94 | }; | ||
| 95 | } | ||
| 96 | }, | ||
| 97 | focaBotoneraLateralService: {}, | ||
| 98 | focaModalService: focaModalService, | ||
| 99 | notaPedidoBusinessService: {}, | ||
| 100 | $rootScope: { | ||
| 101 | $on: function() { } | ||
| 102 | }, | ||
| 103 | focaSeguimientoService: {}, | ||
| 104 | APP: {}, | ||
| 105 | focaLoginService: {}, | ||
| 106 | $localStorage: {}, | ||
| 107 | $watch: function() { }, | ||
| 108 | $broadcast: function() {} | ||
| 109 | }); | ||
| 110 | |||
| 111 | //act | ||
| 112 | scope.notaPedido = { | ||
| 113 | vendedor: { | ||
| 114 | id: null | ||
| 115 | } | ||
| 116 | }; | ||
| 117 | spyOn(focaModalService, 'alert'); | ||
| 118 | scope.crearNotaPedido(); | ||
| 119 | |||
| 120 | //expect | ||
| 121 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Vendedor'); | ||
| 122 | }); | ||
| 123 | |||
| 124 | it('la funcion $scope.crearNotaPedido muestra alerta cuando cliente es null', function() { | 67 | it('la funcion $scope.crearNotaPedido muestra alerta cuando cliente es null', function() { |
| 125 | 68 | ||
| 126 | //arrange | 69 | //arrange |
| 127 | var scope = { | 70 | var scope = { |
| 128 | $watch: function() { }, | 71 | $watch: function() { }, |
| 129 | $broadcast: function() {} | 72 | $broadcast: function() {} |
| 130 | }; | 73 | }; |
| 131 | var focaModalService = { | 74 | var focaModalService = { |
| 132 | alert: function() { } | 75 | alert: function() { } |
| 133 | }; | 76 | }; |
| 134 | 77 | ||
| 135 | $controler('notaPedidoCtrl', { | 78 | $controler('notaPedidoCtrl', { |
| 136 | $scope: scope, | 79 | $scope: scope, |
| 137 | $uibModal: {}, | 80 | $uibModal: {}, |
| 138 | $location: {}, | 81 | $location: {}, |
| 139 | $filter: filter, | 82 | $filter: filter, |
| 140 | $timeout: timeout, | 83 | $timeout: timeout, |
| 141 | crearNotaPedidoService: { | 84 | crearNotaPedidoService: { |
| 142 | getNumeroNotaPedido: function() { | 85 | getNumeroNotaPedido: function() { |
| 143 | return { | 86 | return { |
| 144 | then: function() { } | 87 | then: function() { } |
| 145 | }; | 88 | }; |
| 146 | }, | 89 | }, |
| 147 | getBotonera: function() { }, | 90 | getBotonera: function() { }, |
| 148 | getCotizacionByIdMoneda: function() { | 91 | getCotizacionByIdMoneda: function() { |
| 149 | return { | 92 | return { |
| 150 | then: function() {} | 93 | then: function() {} |
| 151 | }; | 94 | }; |
| 152 | } | 95 | } |
| 153 | }, | 96 | }, |
| 154 | focaBotoneraLateralService: {}, | 97 | focaBotoneraLateralService: {}, |
| 155 | focaModalService: focaModalService, | 98 | focaModalService: focaModalService, |
| 156 | notaPedidoBusinessService: {}, | 99 | notaPedidoBusinessService: {}, |
| 157 | $rootScope: { | 100 | $rootScope: { |
| 158 | $on: function() { } | 101 | $on: function() { } |
| 159 | }, | 102 | }, |
| 160 | focaSeguimientoService: {}, | 103 | focaSeguimientoService: {}, |
| 161 | APP: {}, | 104 | APP: {}, |
| 162 | focaLoginService: {}, | 105 | focaLoginService: {}, |
| 163 | $localStorage: {}, | 106 | $localStorage: {}, |
| 164 | $watch: function() { }, | 107 | $watch: function() { }, |
| 165 | $broadcast: function() {} | 108 | $broadcast: function() {} |
| 166 | }); | 109 | }); |
| 167 | 110 | ||
| 168 | scope.notaPedido = { | 111 | scope.notaPedido = { |
| 169 | vendedor: { | 112 | vendedor: { |
| 170 | id: true | 113 | id: true |
| 171 | }, | 114 | }, |
| 172 | cliente:{ | 115 | cliente:{ |
| 173 | COD: false | 116 | COD: false |
| 174 | } | 117 | } |
| 175 | }; | 118 | }; |
| 176 | 119 | ||
| 177 | //act | 120 | //act |
| 178 | spyOn(focaModalService, 'alert'); | 121 | spyOn(focaModalService, 'alert'); |
| 179 | scope.crearNotaPedido(); | 122 | scope.crearNotaPedido(); |
| 180 | 123 | ||
| 181 | //expect | 124 | //expect |
| 182 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Cliente'); | 125 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Cliente'); |
| 183 | }); | 126 | }); |
| 184 | 127 | ||
| 185 | it('funcion $scope.crearNotaPedido muestra alerta cuando proveedor es null', function() { | 128 | it('funcion $scope.crearNotaPedido muestra alerta cuando proveedor es null', function() { |
| 186 | 129 | ||
| 187 | //arrange | 130 | //arrange |
| 188 | var scope = { | 131 | var scope = { |
| 189 | $watch: function() { }, | 132 | $watch: function() { }, |
| 190 | $broadcast: function() {} | 133 | $broadcast: function() {} |
| 191 | }; | 134 | }; |
| 192 | var focaModalService = { | 135 | var focaModalService = { |
| 193 | alert: function() { } | 136 | alert: function() { } |
| 194 | }; | 137 | }; |
| 195 | 138 | ||
| 196 | $controler('notaPedidoCtrl', { | 139 | $controler('notaPedidoCtrl', { |
| 197 | $scope: scope, | 140 | $scope: scope, |
| 198 | $uibModal: {}, | 141 | $uibModal: {}, |
| 199 | $location: {}, | 142 | $location: {}, |
| 200 | $filter: filter, | 143 | $filter: filter, |
| 201 | $timeout: timeout, | 144 | $timeout: timeout, |
| 202 | crearNotaPedidoService: { | 145 | crearNotaPedidoService: { |
| 203 | getNumeroNotaPedido: function() { | 146 | getNumeroNotaPedido: function() { |
| 204 | return { | 147 | return { |
| 205 | then: function() { } | 148 | then: function() { } |
| 206 | }; | 149 | }; |
| 207 | }, | 150 | }, |
| 208 | getBotonera: function() { }, | 151 | getBotonera: function() { }, |
| 209 | getCotizacionByIdMoneda: function() { | 152 | getCotizacionByIdMoneda: function() { |
| 210 | return { | 153 | return { |
| 211 | then: function() {} | 154 | then: function() {} |
| 212 | }; | 155 | }; |
| 213 | } | 156 | } |
| 214 | }, | 157 | }, |
| 215 | focaBotoneraLateralService: {}, | 158 | focaBotoneraLateralService: {}, |
| 216 | focaModalService: focaModalService, | 159 | focaModalService: focaModalService, |
| 217 | notaPedidoBusinessService: {}, | 160 | notaPedidoBusinessService: {}, |
| 218 | $rootScope: { | 161 | $rootScope: { |
| 219 | $on: function() { } | 162 | $on: function() { } |
| 220 | }, | 163 | }, |
| 221 | focaSeguimientoService: {}, | 164 | focaSeguimientoService: {}, |
| 222 | APP: {}, | 165 | APP: {}, |
| 223 | focaLoginService: {}, | 166 | focaLoginService: {}, |
| 224 | $localStorage: {}, | 167 | $localStorage: {}, |
| 225 | $watch: function() { }, | 168 | $watch: function() { }, |
| 226 | $broadcast: function() {} | 169 | $broadcast: function() {} |
| 227 | }); | 170 | }); |
| 228 | 171 | ||
| 229 | scope.notaPedido = { | 172 | scope.notaPedido = { |
| 230 | vendedor: { | 173 | vendedor: { |
| 231 | id: true | 174 | id: true |
| 232 | }, | 175 | }, |
| 233 | cliente:{ | 176 | cliente:{ |
| 234 | COD: true | 177 | COD: true |
| 235 | }, | 178 | }, |
| 236 | proveedor:{ | 179 | proveedor:{ |
| 237 | COD: null | 180 | COD: null |
| 238 | } | 181 | } |
| 239 | }; | 182 | }; |
| 240 | 183 | ||
| 241 | //act | 184 | //act |
| 242 | spyOn(focaModalService, 'alert'); | 185 | spyOn(focaModalService, 'alert'); |
| 243 | scope.crearNotaPedido(); | 186 | scope.crearNotaPedido(); |
| 244 | 187 | ||
| 245 | //expect | 188 | //expect |
| 246 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Proveedor'); | 189 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Proveedor'); |
| 247 | }); | 190 | }); |
| 248 | 191 | ||
| 249 | it('funcion $scope.crearNotaPedido muestra alerta cuando Moneda es null', function() { | 192 | it('funcion $scope.crearNotaPedido muestra alerta cuando Moneda es null', function() { |
| 250 | 193 | ||
| 251 | //arrange | 194 | //arrange |
| 252 | var scope = { | 195 | var scope = { |
| 253 | $watch: function() { }, | 196 | $watch: function() { }, |
| 254 | $broadcast: function() {} | 197 | $broadcast: function() {} |
| 255 | }; | 198 | }; |
| 256 | var focaModalService = { | 199 | var focaModalService = { |
| 257 | alert: function() { } | 200 | alert: function() { } |
| 258 | }; | 201 | }; |
| 259 | 202 | ||
| 260 | $controler('notaPedidoCtrl', { | 203 | $controler('notaPedidoCtrl', { |
| 261 | $scope: scope, | 204 | $scope: scope, |
| 262 | $uibModal: {}, | 205 | $uibModal: {}, |
| 263 | $location: {}, | 206 | $location: {}, |
| 264 | $filter: filter, | 207 | $filter: filter, |
| 265 | $timeout: timeout, | 208 | $timeout: timeout, |
| 266 | crearNotaPedidoService: { | 209 | crearNotaPedidoService: { |
| 267 | getNumeroNotaPedido: function() { | 210 | getNumeroNotaPedido: function() { |
| 268 | return { | 211 | return { |
| 269 | then: function() { } | 212 | then: function() { } |
| 270 | }; | 213 | }; |
| 271 | }, | 214 | }, |
| 272 | getBotonera: function() { }, | 215 | getBotonera: function() { }, |
| 273 | getCotizacionByIdMoneda: function() { | 216 | getCotizacionByIdMoneda: function() { |
| 274 | return { | 217 | return { |
| 275 | then: function() {} | 218 | then: function() {} |
| 276 | }; | 219 | }; |
| 277 | } | 220 | } |
| 278 | }, | 221 | }, |
| 279 | focaBotoneraLateralService: {}, | 222 | focaBotoneraLateralService: {}, |
| 280 | focaModalService: focaModalService, | 223 | focaModalService: focaModalService, |
| 281 | notaPedidoBusinessService: {}, | 224 | notaPedidoBusinessService: {}, |
| 282 | $rootScope: { | 225 | $rootScope: { |
| 283 | $on: function() { } | 226 | $on: function() { } |
| 284 | }, | 227 | }, |
| 285 | focaSeguimientoService: {}, | 228 | focaSeguimientoService: {}, |
| 286 | APP: {}, | 229 | APP: {}, |
| 287 | focaLoginService: {}, | 230 | focaLoginService: {}, |
| 288 | $localStorage: {}, | 231 | $localStorage: {}, |
| 289 | $watch: function() { }, | 232 | $watch: function() { }, |
| 290 | $broadcast: function() {} | 233 | $broadcast: function() {} |
| 291 | }); | 234 | }); |
| 292 | 235 | ||
| 293 | scope.notaPedido = { | 236 | scope.notaPedido = { |
| 294 | vendedor: { | 237 | vendedor: { |
| 295 | id: true | 238 | id: true |
| 296 | }, | 239 | }, |
| 297 | cliente:{ | 240 | cliente:{ |
| 298 | COD: true | 241 | COD: true |
| 299 | }, | 242 | }, |
| 300 | proveedor:{ | 243 | proveedor:{ |
| 301 | COD: true | 244 | COD: true |
| 302 | }, | 245 | }, |
| 303 | cotizacion: { | 246 | cotizacion: { |
| 304 | ID: true, | 247 | ID: true, |
| 305 | moneda:{ | 248 | moneda:{ |
| 306 | ID: null | 249 | ID: null |
| 307 | } | 250 | } |
| 308 | } | 251 | } |
| 309 | }; | 252 | }; |
| 310 | 253 | ||
| 311 | //act | 254 | //act |
| 312 | spyOn(focaModalService, 'alert'); | 255 | spyOn(focaModalService, 'alert'); |
| 313 | scope.crearNotaPedido(); | 256 | scope.crearNotaPedido(); |
| 314 | 257 | ||
| 315 | //expect | 258 | //expect |
| 316 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Moneda'); | 259 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Moneda'); |
| 317 | }); | 260 | }); |
| 318 | 261 | ||
| 319 | it('funcion $scope.crearNotaPedido muestra alerta cuando cotizacion es null', function() { | 262 | it('funcion $scope.crearNotaPedido muestra alerta cuando cotizacion es null', function() { |
| 320 | 263 | ||
| 321 | //arrange | 264 | //arrange |
| 322 | var scope = { | 265 | var scope = { |
| 323 | $watch: function() { }, | 266 | $watch: function() { }, |
| 324 | $broadcast: function() {} | 267 | $broadcast: function() {} |
| 325 | }; | 268 | }; |
| 326 | var focaModalService = { | 269 | var focaModalService = { |
| 327 | alert: function() { } | 270 | alert: function() { } |
| 328 | }; | 271 | }; |
| 329 | 272 | ||
| 330 | $controler('notaPedidoCtrl', { | 273 | $controler('notaPedidoCtrl', { |
| 331 | $scope: scope, | 274 | $scope: scope, |
| 332 | $uibModal: {}, | 275 | $uibModal: {}, |
| 333 | $location: {}, | 276 | $location: {}, |
| 334 | $filter: filter, | 277 | $filter: filter, |
| 335 | $timeout: timeout, | 278 | $timeout: timeout, |
| 336 | crearNotaPedidoService: { | 279 | crearNotaPedidoService: { |
| 337 | getNumeroNotaPedido: function() { | 280 | getNumeroNotaPedido: function() { |
| 338 | return { | 281 | return { |
| 339 | then: function() { } | 282 | then: function() { } |
| 340 | }; | 283 | }; |
| 341 | }, | 284 | }, |
| 342 | getBotonera: function() { }, | 285 | getBotonera: function() { }, |
| 343 | getCotizacionByIdMoneda: function() { | 286 | getCotizacionByIdMoneda: function() { |
| 344 | return { | 287 | return { |
| 345 | then: function() {} | 288 | then: function() {} |
| 346 | }; | 289 | }; |
| 347 | } | 290 | } |
| 348 | }, | 291 | }, |
| 349 | focaBotoneraLateralService: {}, | 292 | focaBotoneraLateralService: {}, |
| 350 | focaModalService: focaModalService, | 293 | focaModalService: focaModalService, |
| 351 | notaPedidoBusinessService: {}, | 294 | notaPedidoBusinessService: {}, |
| 352 | $rootScope: { | 295 | $rootScope: { |
| 353 | $on: function() { } | 296 | $on: function() { } |
| 354 | }, | 297 | }, |
| 355 | focaSeguimientoService: {}, | 298 | focaSeguimientoService: {}, |
| 356 | APP: {}, | 299 | APP: {}, |
| 357 | focaLoginService: {}, | 300 | focaLoginService: {}, |
| 358 | $localStorage: {}, | 301 | $localStorage: {}, |
| 359 | $watch: function() { }, | 302 | $watch: function() { }, |
| 360 | $broadcast: function() {} | 303 | $broadcast: function() {} |
| 361 | }); | 304 | }); |
| 362 | 305 | ||
| 363 | scope.notaPedido = { | 306 | scope.notaPedido = { |
| 364 | vendedor: { | 307 | vendedor: { |
| 365 | id: true | 308 | id: true |
| 366 | }, | 309 | }, |
| 367 | cliente:{ | 310 | cliente:{ |
| 368 | COD: true | 311 | COD: true |
| 369 | }, | 312 | }, |
| 370 | proveedor:{ | 313 | proveedor:{ |
| 371 | COD: true | 314 | COD: true |
| 372 | }, | 315 | }, |
| 373 | cotizacion:{ | 316 | cotizacion:{ |
| 374 | ID: null, | 317 | ID: null, |
| 375 | moneda: { | 318 | moneda: { |
| 376 | ID: true | 319 | ID: true |
| 377 | } | 320 | } |
| 378 | } | 321 | } |
| 379 | }; | 322 | }; |
| 380 | 323 | ||
| 381 | //act | 324 | //act |
| 382 | spyOn(focaModalService, 'alert'); | 325 | spyOn(focaModalService, 'alert'); |
| 383 | scope.crearNotaPedido(); | 326 | scope.crearNotaPedido(); |
| 384 | 327 | ||
| 385 | //expect | 328 | //expect |
| 386 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Cotización'); | 329 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Cotización'); |
| 387 | }); | 330 | }); |
| 388 | 331 | ||
| 389 | it('funcion $scope.crearNotaPedido muestra alerta cuando plazos es null', function() { | 332 | it('funcion $scope.crearNotaPedido muestra alerta cuando plazos es null', function() { |
| 390 | 333 | ||
| 391 | //arrange | 334 | //arrange |
| 392 | var scope = { | 335 | var scope = { |
| 393 | $watch: function() { }, | 336 | $watch: function() { }, |
| 394 | $broadcast: function() {} | 337 | $broadcast: function() {} |
| 395 | }; | 338 | }; |
| 396 | var focaModalService = { | 339 | var focaModalService = { |
| 397 | alert: function() { } | 340 | alert: function() { } |
| 398 | }; | 341 | }; |
| 399 | 342 | ||
| 400 | $controler('notaPedidoCtrl', { | 343 | $controler('notaPedidoCtrl', { |
| 401 | $scope: scope, | 344 | $scope: scope, |
| 402 | $uibModal: {}, | 345 | $uibModal: {}, |
| 403 | $location: {}, | 346 | $location: {}, |
| 404 | $filter: filter, | 347 | $filter: filter, |
| 405 | $timeout: timeout, | 348 | $timeout: timeout, |
| 406 | crearNotaPedidoService: { | 349 | crearNotaPedidoService: { |
| 407 | getNumeroNotaPedido: function() { | 350 | getNumeroNotaPedido: function() { |
| 408 | return { | 351 | return { |
| 409 | then: function() { } | 352 | then: function() { } |
| 410 | }; | 353 | }; |
| 411 | }, | 354 | }, |
| 412 | getBotonera: function() { }, | 355 | getBotonera: function() { }, |
| 413 | getCotizacionByIdMoneda: function() { | 356 | getCotizacionByIdMoneda: function() { |
| 414 | return { | 357 | return { |
| 415 | then: function() {} | 358 | then: function() {} |
| 416 | }; | 359 | }; |
| 417 | } | 360 | } |
| 418 | }, | 361 | }, |
| 419 | focaBotoneraLateralService: {}, | 362 | focaBotoneraLateralService: {}, |
| 420 | focaModalService: focaModalService, | 363 | focaModalService: focaModalService, |
| 421 | notaPedidoBusinessService: {}, | 364 | notaPedidoBusinessService: {}, |
| 422 | $rootScope: { | 365 | $rootScope: { |
| 423 | $on: function() { } | 366 | $on: function() { } |
| 424 | }, | 367 | }, |
| 425 | focaSeguimientoService: {}, | 368 | focaSeguimientoService: {}, |
| 426 | APP: {}, | 369 | APP: {}, |
| 427 | focaLoginService: {}, | 370 | focaLoginService: {}, |
| 428 | $localStorage: {}, | 371 | $localStorage: {}, |
| 429 | $watch: function() { }, | 372 | $watch: function() { }, |
| 430 | $broadcast: function() {} | 373 | $broadcast: function() {} |
| 431 | }); | 374 | }); |
| 432 | 375 | ||
| 433 | scope.notaPedido = { | 376 | scope.notaPedido = { |
| 434 | vendedor: { | 377 | vendedor: { |
| 435 | id: true | 378 | id: true |
| 436 | }, | 379 | }, |
| 437 | cliente:{ | 380 | cliente:{ |
| 438 | COD: true | 381 | COD: true |
| 439 | }, | 382 | }, |
| 440 | proveedor:{ | 383 | proveedor:{ |
| 441 | COD: true | 384 | COD: true |
| 442 | }, | 385 | }, |
| 443 | cotizacion:{ | 386 | cotizacion:{ |
| 444 | ID: true, | 387 | ID: true, |
| 445 | moneda:{ | 388 | moneda:{ |
| 446 | ID: true | 389 | ID: true |
| 447 | } | 390 | } |
| 448 | } | 391 | } |
| 449 | }; | 392 | }; |
| 450 | 393 | ||
| 451 | scope.plazosPagos = null; | 394 | scope.plazosPagos = null; |
| 452 | 395 | ||
| 453 | //act | 396 | //act |
| 454 | spyOn(focaModalService, 'alert'); | 397 | spyOn(focaModalService, 'alert'); |
| 455 | scope.crearNotaPedido(); | 398 | scope.crearNotaPedido(); |
| 456 | 399 | ||
| 457 | //expect | 400 | //expect |
| 458 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Precios y Condiciones'); | 401 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Precios y Condiciones'); |
| 459 | }); | 402 | }); |
| 460 | 403 | ||
| 461 | it('funcion $scope.crearNotaPedido muestra alerta cuando flete es null', function() { | 404 | it('funcion $scope.crearNotaPedido muestra alerta cuando flete es null', function() { |
| 462 | 405 | ||
| 463 | //arrange | 406 | //arrange |
| 464 | var scope = { | 407 | var scope = { |
| 465 | $watch: function() { }, | 408 | $watch: function() { }, |
| 466 | $broadcast: function() {} | 409 | $broadcast: function() {} |
| 467 | }; | 410 | }; |
| 468 | var focaModalService = { | 411 | var focaModalService = { |
| 469 | alert: function() { } | 412 | alert: function() { } |
| 470 | }; | 413 | }; |
| 471 | 414 | ||
| 472 | $controler('notaPedidoCtrl', { | 415 | $controler('notaPedidoCtrl', { |
| 473 | $scope: scope, | 416 | $scope: scope, |
| 474 | $uibModal: {}, | 417 | $uibModal: {}, |
| 475 | $location: {}, | 418 | $location: {}, |
| 476 | $filter: filter, | 419 | $filter: filter, |
| 477 | $timeout: timeout, | 420 | $timeout: timeout, |
| 478 | crearNotaPedidoService: { | 421 | crearNotaPedidoService: { |
| 479 | getNumeroNotaPedido: function() { | 422 | getNumeroNotaPedido: function() { |
| 480 | return { | 423 | return { |
| 481 | then: function() { } | 424 | then: function() { } |
| 482 | }; | 425 | }; |
| 483 | }, | 426 | }, |
| 484 | getBotonera: function() { }, | 427 | getBotonera: function() { }, |
| 485 | getCotizacionByIdMoneda: function() { | 428 | getCotizacionByIdMoneda: function() { |
| 486 | return { | 429 | return { |
| 487 | then: function() {} | 430 | then: function() {} |
| 488 | }; | 431 | }; |
| 489 | } | 432 | } |
| 490 | }, | 433 | }, |
| 491 | focaBotoneraLateralService: {}, | 434 | focaBotoneraLateralService: {}, |
| 492 | focaModalService: focaModalService, | 435 | focaModalService: focaModalService, |
| 493 | notaPedidoBusinessService: {}, | 436 | notaPedidoBusinessService: {}, |
| 494 | $rootScope: { | 437 | $rootScope: { |
| 495 | $on: function() { } | 438 | $on: function() { } |
| 496 | }, | 439 | }, |
| 497 | focaSeguimientoService: {}, | 440 | focaSeguimientoService: {}, |
| 498 | APP: {}, | 441 | APP: {}, |
| 499 | focaLoginService: {}, | 442 | focaLoginService: {}, |
| 500 | $localStorage: {}, | 443 | $localStorage: {}, |
| 501 | $watch: function() { }, | 444 | $watch: function() { }, |
| 502 | $broadcast: function() {} | 445 | $broadcast: function() {} |
| 503 | }); | 446 | }); |
| 504 | 447 | ||
| 505 | scope.notaPedido = { | 448 | scope.notaPedido = { |
| 506 | vendedor: { | 449 | vendedor: { |
| 507 | id: true | 450 | id: true |
| 508 | }, | 451 | }, |
| 509 | cliente:{ | 452 | cliente:{ |
| 510 | COD: true | 453 | COD: true |
| 511 | }, | 454 | }, |
| 512 | proveedor:{ | 455 | proveedor:{ |
| 513 | COD: true | 456 | COD: true |
| 514 | }, | 457 | }, |
| 515 | cotizacion:{ | 458 | cotizacion:{ |
| 516 | ID: true, | 459 | ID: true, |
| 517 | moneda:{ | 460 | moneda:{ |
| 518 | ID: true | 461 | ID: true |
| 519 | } | 462 | } |
| 520 | }, | 463 | }, |
| 521 | flete: null, | 464 | flete: null, |
| 522 | notaPedidoPlazo: [] | 465 | notaPedidoPlazo: [] |
| 523 | }; | 466 | }; |
| 524 | 467 | ||
| 525 | scope.plazosPagos = true; | 468 | scope.plazosPagos = true; |
| 526 | 469 | ||
| 527 | //act | 470 | //act |
| 528 | spyOn(focaModalService, 'alert'); | 471 | spyOn(focaModalService, 'alert'); |
| 529 | scope.crearNotaPedido(); | 472 | scope.crearNotaPedido(); |
| 530 | 473 | ||
| 531 | //expect | 474 | //expect |
| 532 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Flete'); | 475 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Flete'); |
| 533 | }); | 476 | }); |
| 534 | 477 | ||
| 535 | it('funcion $scope.crearNotaPedido muestra alerta cuando domicilio es null', function() { | 478 | it('funcion $scope.crearNotaPedido muestra alerta cuando domicilio es null', function() { |
| 536 | 479 | ||
| 537 | //arrange | 480 | //arrange |
| 538 | var scope = { | 481 | var scope = { |
| 539 | $watch: function() { }, | 482 | $watch: function() { }, |
| 540 | $broadcast: function() {} | 483 | $broadcast: function() {} |
| 541 | }; | 484 | }; |
| 542 | var focaModalService = { | 485 | var focaModalService = { |
| 543 | alert: function() { } | 486 | alert: function() { } |
| 544 | }; | 487 | }; |
| 545 | 488 | ||
| 546 | $controler('notaPedidoCtrl', { | 489 | $controler('notaPedidoCtrl', { |
| 547 | $scope: scope, | 490 | $scope: scope, |
| 548 | $uibModal: {}, | 491 | $uibModal: {}, |
| 549 | $location: {}, | 492 | $location: {}, |
| 550 | $filter: filter, | 493 | $filter: filter, |
| 551 | $timeout: timeout, | 494 | $timeout: timeout, |
| 552 | crearNotaPedidoService: { | 495 | crearNotaPedidoService: { |
| 553 | getNumeroNotaPedido: function() { | 496 | getNumeroNotaPedido: function() { |
| 554 | return { | 497 | return { |
| 555 | then: function() { } | 498 | then: function() { } |
| 556 | }; | 499 | }; |
| 557 | }, | 500 | }, |
| 558 | getBotonera: function() { }, | 501 | getBotonera: function() { }, |
| 559 | getCotizacionByIdMoneda: function() { | 502 | getCotizacionByIdMoneda: function() { |
| 560 | return { | 503 | return { |
| 561 | then: function() {} | 504 | then: function() {} |
| 562 | }; | 505 | }; |
| 563 | } | 506 | } |
| 564 | }, | 507 | }, |
| 565 | focaBotoneraLateralService: {}, | 508 | focaBotoneraLateralService: {}, |
| 566 | focaModalService: focaModalService, | 509 | focaModalService: focaModalService, |
| 567 | notaPedidoBusinessService: {}, | 510 | notaPedidoBusinessService: {}, |
| 568 | $rootScope: { | 511 | $rootScope: { |
| 569 | $on: function() { } | 512 | $on: function() { } |
| 570 | }, | 513 | }, |
| 571 | focaSeguimientoService: {}, | 514 | focaSeguimientoService: {}, |
| 572 | APP: {}, | 515 | APP: {}, |
| 573 | focaLoginService: {}, | 516 | focaLoginService: {}, |
| 574 | $localStorage: {}, | 517 | $localStorage: {}, |
| 575 | $watch: function() { }, | 518 | $watch: function() { }, |
| 576 | $broadcast: function() {} | 519 | $broadcast: function() {} |
| 577 | }); | 520 | }); |
| 578 | 521 | ||
| 579 | scope.notaPedido = { | 522 | scope.notaPedido = { |
| 580 | vendedor: { | 523 | vendedor: { |
| 581 | id: true | 524 | id: true |
| 582 | }, | 525 | }, |
| 583 | cliente:{ | 526 | cliente:{ |
| 584 | COD: true | 527 | COD: true |
| 585 | }, | 528 | }, |
| 586 | proveedor:{ | 529 | proveedor:{ |
| 587 | COD: true | 530 | COD: true |
| 588 | }, | 531 | }, |
| 589 | cotizacion:{ | 532 | cotizacion:{ |
| 590 | ID: true, | 533 | ID: true, |
| 591 | moneda:{ | 534 | moneda:{ |
| 592 | ID: true | 535 | ID: true |
| 593 | } | 536 | } |
| 594 | }, | 537 | }, |
| 595 | flete: true, | 538 | flete: true, |
| 596 | domicilioStamp: null, | 539 | domicilioStamp: null, |
| 597 | notaPedidoPlazo: [] | 540 | notaPedidoPlazo: [] |
| 598 | }; | 541 | }; |
| 599 | 542 | ||
| 600 | scope.plazosPagos = true; | 543 | scope.plazosPagos = true; |
| 601 | 544 | ||
| 602 | //act | 545 | //act |
| 603 | spyOn(focaModalService, 'alert'); | 546 | spyOn(focaModalService, 'alert'); |
| 604 | scope.crearNotaPedido(); | 547 | scope.crearNotaPedido(); |
| 605 | 548 | ||
| 606 | //expect | 549 | //expect |
| 607 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Domicilio'); | 550 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Domicilio'); |
| 608 | }); | 551 | }); |
| 609 | 552 | ||
| 610 | it('funcion $scope.crearNotaPedido muestra alerta cuando no se cargaron articulos', | 553 | it('funcion $scope.crearNotaPedido muestra alerta cuando no se cargaron articulos', |
| 611 | function() | 554 | function() |
| 612 | { | 555 | { |
| 613 | 556 | ||
| 614 | //arrange | 557 | //arrange |
| 615 | var scope = { | 558 | var scope = { |
| 616 | $watch: function() { }, | 559 | $watch: function() { }, |
| 617 | $broadcast: function() {} | 560 | $broadcast: function() {} |
| 618 | }; | 561 | }; |
| 619 | var focaModalService = { | 562 | var focaModalService = { |
| 620 | alert: function() { } | 563 | alert: function() { } |
| 621 | }; | 564 | }; |
| 622 | 565 | ||
| 623 | $controler('notaPedidoCtrl', { | 566 | $controler('notaPedidoCtrl', { |
| 624 | $scope: scope, | 567 | $scope: scope, |
| 625 | $uibModal: {}, | 568 | $uibModal: {}, |
| 626 | $location: {}, | 569 | $location: {}, |
| 627 | $filter: filter, | 570 | $filter: filter, |
| 628 | $timeout: timeout, | 571 | $timeout: timeout, |
| 629 | crearNotaPedidoService: { | 572 | crearNotaPedidoService: { |
| 630 | getNumeroNotaPedido: function() { | 573 | getNumeroNotaPedido: function() { |
| 631 | return { | 574 | return { |
| 632 | then: function() {} | 575 | then: function() {} |
| 633 | }; | 576 | }; |
| 634 | }, | 577 | }, |
| 635 | getBotonera: function() { }, | 578 | getBotonera: function() { }, |
| 636 | getCotizacionByIdMoneda: function() { | 579 | getCotizacionByIdMoneda: function() { |
| 637 | return { | 580 | return { |
| 638 | then: function() {} | 581 | then: function() {} |
| 639 | }; | 582 | }; |
| 640 | }, | 583 | }, |
| 641 | crearNotaPedido: function() { | 584 | crearNotaPedido: function() { |
| 642 | return { | 585 | return { |
| 643 | then: function() { } | 586 | then: function() { } |
| 644 | }; | 587 | }; |
| 645 | } | 588 | } |
| 646 | }, | 589 | }, |
| 647 | focaBotoneraLateralService: { | 590 | focaBotoneraLateralService: { |
| 648 | startGuardar: function() {} | 591 | startGuardar: function() {} |
| 649 | }, | 592 | }, |
| 650 | focaModalService: focaModalService, | 593 | focaModalService: focaModalService, |
| 651 | notaPedidoBusinessService: {}, | 594 | notaPedidoBusinessService: {}, |
| 652 | $rootScope: { | 595 | $rootScope: { |
| 653 | $on: function() { } | 596 | $on: function() { } |
| 654 | }, | 597 | }, |
| 655 | focaSeguimientoService: {}, | 598 | focaSeguimientoService: {}, |
| 656 | APP: {}, | 599 | APP: {}, |
| 657 | focaLoginService: {}, | 600 | focaLoginService: {}, |
| 658 | $localStorage: {}, | 601 | $localStorage: {}, |
| 659 | $watch: function() { }, | 602 | $watch: function() { }, |
| 660 | $broadcast: function() {} | 603 | $broadcast: function() {} |
| 661 | }); | 604 | }); |
| 662 | 605 | ||
| 663 | scope.notaPedido = { | 606 | scope.notaPedido = { |
| 664 | vendedor: { | 607 | vendedor: { |
| 665 | id: true | 608 | id: true |
| 666 | }, | 609 | }, |
| 667 | cliente:{ | 610 | cliente:{ |
| 668 | COD: true | 611 | COD: true |
| 669 | }, | 612 | }, |
| 670 | proveedor:{ | 613 | proveedor:{ |
| 671 | COD: true | 614 | COD: true |
| 672 | }, | 615 | }, |
| 673 | cotizacion:{ | 616 | cotizacion:{ |
| 674 | ID: true, | 617 | ID: true, |
| 675 | moneda:{ | 618 | moneda:{ |
| 676 | ID: true | 619 | ID: true |
| 677 | } | 620 | } |
| 678 | }, | 621 | }, |
| 679 | precioCondicion: { | 622 | precioCondicion: { |
| 680 | id: true | 623 | id: true |
| 681 | }, | 624 | }, |
| 682 | domicilio: { | 625 | domicilio: { |
| 683 | id: true | 626 | id: true |
| 684 | }, | 627 | }, |
| 685 | flete: true, | 628 | flete: true, |
| 686 | domicilioStamp: true, | 629 | domicilioStamp: true, |
| 687 | notaPedidoPlazo: [], | 630 | notaPedidoPlazo: [], |
| 688 | articulosNotaPedido: [], | 631 | articulosNotaPedido: [], |
| 689 | fechaCarga: true | 632 | fechaCarga: true |
| 690 | }; | 633 | }; |
| 691 | 634 | ||
| 692 | scope.articulosTabla = []; | 635 | scope.articulosTabla = []; |
| 693 | 636 | ||
| 694 | //act | 637 | //act |
| 695 | spyOn(focaModalService, 'alert'); | 638 | spyOn(focaModalService, 'alert'); |
| 696 | scope.crearNotaPedido(); | 639 | scope.crearNotaPedido(); |
| 697 | 640 | ||
| 698 | //expect | 641 | //expect |
| 699 | expect(focaModalService.alert) | 642 | expect(focaModalService.alert) |
| 700 | .toHaveBeenCalledWith('Debe cargar al menos un articulo'); | 643 | .toHaveBeenCalledWith('Debe cargar al menos un articulo'); |
| 701 | }); | 644 | }); |
| 702 | 645 | ||
| 703 | it('funcion $scope.crearNotaPedido llama startGuardar', function() { | 646 | it('funcion $scope.crearNotaPedido llama startGuardar', function() { |
| 704 | 647 | ||
| 705 | //arrange | 648 | //arrange |
| 706 | var scope = { | 649 | var scope = { |
| 707 | $watch: function() { }, | 650 | $watch: function() { }, |
| 708 | $broadcast: function() {} | 651 | $broadcast: function() {} |
| 709 | }; | 652 | }; |
| 710 | var focaBotoneraLateralService = { | 653 | var focaBotoneraLateralService = { |
| 711 | startGuardar: function() { } | 654 | startGuardar: function() { } |
| 712 | }; | 655 | }; |
| 713 | 656 | ||
| 714 | $controler('notaPedidoCtrl', { | 657 | $controler('notaPedidoCtrl', { |
| 715 | $scope: scope, | 658 | $scope: scope, |
| 716 | $uibModal: {}, | 659 | $uibModal: {}, |
| 717 | $location: {}, | 660 | $location: {}, |
| 718 | $filter: filter, | 661 | $filter: filter, |
| 719 | $timeout: timeout, | 662 | $timeout: timeout, |
| 720 | crearNotaPedidoService: { | 663 | crearNotaPedidoService: { |
| 721 | getNumeroNotaPedido: function() { | 664 | getNumeroNotaPedido: function() { |
| 722 | return { | 665 | return { |
| 723 | then: function() { } | 666 | then: function() { } |
| 724 | }; | 667 | }; |
| 725 | }, | 668 | }, |
| 726 | getBotonera: function() { }, | 669 | getBotonera: function() { }, |
| 727 | getCotizacionByIdMoneda: function() { | 670 | getCotizacionByIdMoneda: function() { |
| 728 | return { | 671 | return { |
| 729 | then: function() {} | 672 | then: function() {} |
| 730 | }; | 673 | }; |
| 731 | }, | 674 | }, |
| 732 | crearNotaPedido: function() { | 675 | crearNotaPedido: function() { |
| 733 | return { | 676 | return { |
| 734 | then: function() { } | 677 | then: function() { } |
| 735 | }; | 678 | }; |
| 736 | } | 679 | } |
| 737 | }, | 680 | }, |
| 738 | focaBotoneraLateralService: focaBotoneraLateralService, | 681 | focaBotoneraLateralService: focaBotoneraLateralService, |
| 739 | focaModalService: { | 682 | focaModalService: { |
| 740 | alert: function() {} | 683 | alert: function() {} |
| 741 | }, | 684 | }, |
| 742 | notaPedidoBusinessService: {}, | 685 | notaPedidoBusinessService: {}, |
| 743 | $rootScope: { | 686 | $rootScope: { |
| 744 | $on: function() { } | 687 | $on: function() { } |
| 745 | }, | 688 | }, |
| 746 | focaSeguimientoService: {}, | 689 | focaSeguimientoService: {}, |
| 747 | APP: {}, | 690 | APP: {}, |
| 748 | focaLoginService: {}, | 691 | focaLoginService: {}, |
| 749 | $localStorage: {}, | 692 | $localStorage: {}, |
| 750 | $watch: function() { }, | 693 | $watch: function() { }, |
| 751 | $broadcast: function() {} | 694 | $broadcast: function() {} |
| 752 | }); | 695 | }); |
| 753 | 696 | ||
| 754 | scope.notaPedido = { | 697 | scope.notaPedido = { |
| 755 | vendedor: { | 698 | vendedor: { |
| 756 | id: true | 699 | id: true |
| 757 | }, | 700 | }, |
| 758 | cliente:{ | 701 | cliente:{ |
| 759 | COD: true | 702 | COD: true |
| 760 | }, | 703 | }, |
| 761 | proveedor:{ | 704 | proveedor:{ |
| 762 | COD: true | 705 | COD: true |
| 763 | }, | 706 | }, |
| 764 | cotizacion:{ | 707 | cotizacion:{ |
| 765 | ID: true, | 708 | ID: true, |
| 766 | moneda:{ | 709 | moneda:{ |
| 767 | ID: true | 710 | ID: true |
| 768 | } | 711 | } |
| 769 | }, | 712 | }, |
| 770 | flete: true, | 713 | flete: true, |
| 771 | domicilioStamp: true, | 714 | domicilioStamp: true, |
| 772 | domicilio: { | 715 | domicilio: { |
| 773 | id: true | 716 | id: true |
| 774 | }, | 717 | }, |
| 775 | notaPedidoPlazo: [], | 718 | notaPedidoPlazo: [], |
| 776 | articulosNotaPedido: true, | 719 | articulosNotaPedido: true, |
| 777 | fechaCarga: true | 720 | fechaCarga: true |
| 778 | }; | 721 | }; |
| 779 | 722 | ||
| 780 | scope.plazosPagos = true; | 723 | scope.plazosPagos = true; |
| 781 | scope.articulosTabla = [1]; | 724 | scope.articulosTabla = [1]; |
| 782 | 725 | ||
| 783 | //act | 726 | //act |
| 784 | spyOn(focaBotoneraLateralService, 'startGuardar'); | 727 | spyOn(focaBotoneraLateralService, 'startGuardar'); |
| 785 | scope.crearNotaPedido(scope.notaPedido); | 728 | scope.crearNotaPedido(scope.notaPedido); |
| 786 | 729 | ||
| 787 | //expect | 730 | //expect |
| 788 | expect(focaBotoneraLateralService.startGuardar).toHaveBeenCalled(); | 731 | expect(focaBotoneraLateralService.startGuardar).toHaveBeenCalled(); |
| 789 | }); | 732 | }); |
| 790 | 733 | ||
| 791 | it('funcion $scope.crearNotaPedido llama funciones al guardar', function(done) { | 734 | it('funcion $scope.crearNotaPedido llama funciones al guardar', function(done) { |
| 792 | 735 | ||
| 793 | //arrange | 736 | //arrange |
| 794 | var scope = { | 737 | var scope = { |
| 795 | $watch: function() { }, | 738 | $watch: function() { }, |
| 796 | $broadcast: function() {} | 739 | $broadcast: function() {} |
| 797 | }; | 740 | }; |
| 798 | var focaBotoneraLateralService = { | 741 | var focaBotoneraLateralService = { |
| 799 | startGuardar: function() { }, | 742 | startGuardar: function() { }, |
| 800 | endGuardar: function() { } | 743 | endGuardar: function() { } |
| 801 | }; | 744 | }; |
| 802 | var focaSeguimientoService = { | 745 | var focaSeguimientoService = { |
| 803 | guardarPosicion: function() { } | 746 | guardarPosicion: function() { } |
| 804 | }; | 747 | }; |
| 805 | var notaPedidoBusinessService = { | 748 | var notaPedidoBusinessService = { |
| 806 | addArticulos: function() { }, | 749 | addArticulos: function() { }, |
| 807 | addEstado: function() { } | 750 | addEstado: function() { } |
| 808 | }; | 751 | }; |
| 809 | var crearNotaPedidoService = { | 752 | var crearNotaPedidoService = { |
| 810 | getBotonera: function() { }, | 753 | getBotonera: function() { }, |
| 811 | getCotizacionByIdMoneda: function() { | 754 | getCotizacionByIdMoneda: function() { |
| 812 | return { | 755 | return { |
| 813 | then: function() {} | 756 | then: function() {} |
| 814 | }; | 757 | }; |
| 815 | }, | 758 | }, |
| 816 | crearNotaPedido: function() { | 759 | crearNotaPedido: function() { |
| 817 | return { | 760 | return { |
| 818 | then: function() { } | 761 | then: function() { } |
| 819 | }; | 762 | }; |
| 820 | }, | 763 | }, |
| 821 | getNumeroNotaPedido: function() { | 764 | getNumeroNotaPedido: function() { |
| 822 | return { | 765 | return { |
| 823 | then: function() { } | 766 | then: function() { } |
| 824 | }; | 767 | }; |
| 825 | } | 768 | } |
| 826 | }; | 769 | }; |
| 827 | 770 | ||
| 828 | $controler('notaPedidoCtrl', { | 771 | $controler('notaPedidoCtrl', { |
| 829 | $scope: scope, | 772 | $scope: scope, |
| 830 | $uibModal: {}, | 773 | $uibModal: {}, |
| 831 | $location: {}, | 774 | $location: {}, |
| 832 | $filter: filter, | 775 | $filter: filter, |
| 833 | $timeout: timeout, | 776 | $timeout: timeout, |
| 834 | crearNotaPedidoService: crearNotaPedidoService, | 777 | crearNotaPedidoService: crearNotaPedidoService, |
| 835 | focaBotoneraLateralService: focaBotoneraLateralService, | 778 | focaBotoneraLateralService: focaBotoneraLateralService, |
| 836 | focaModalService: { | 779 | focaModalService: { |
| 837 | alert: function() {} | 780 | alert: function() {} |
| 838 | }, | 781 | }, |
| 839 | notaPedidoBusinessService: notaPedidoBusinessService, | 782 | notaPedidoBusinessService: notaPedidoBusinessService, |
| 840 | $rootScope: { | 783 | $rootScope: { |
| 841 | $on: function() { } | 784 | $on: function() { } |
| 842 | }, | 785 | }, |
| 843 | focaSeguimientoService: focaSeguimientoService, | 786 | focaSeguimientoService: focaSeguimientoService, |
| 844 | APP: {}, | 787 | APP: {}, |
| 845 | focaLoginService: {}, | 788 | focaLoginService: {}, |
| 846 | $localStorage: {}, | 789 | $localStorage: {}, |
| 847 | $watch: function() { }, | 790 | $watch: function() { }, |
| 848 | $broadcast: function() {} | 791 | $broadcast: function() {} |
| 849 | }); | 792 | }); |
| 850 | 793 | ||
| 851 | scope.notaPedido = { | 794 | scope.notaPedido = { |
| 852 | vendedor: { | 795 | vendedor: { |
| 853 | id: true | 796 | id: true |
| 854 | }, | 797 | }, |
| 855 | cliente:{ | 798 | cliente:{ |
| 856 | COD: true | 799 | COD: true |
| 857 | }, | 800 | }, |
| 858 | proveedor:{ | 801 | proveedor:{ |
| 859 | COD: true | 802 | COD: true |
| 860 | }, | 803 | }, |
| 861 | cotizacion:{ | 804 | cotizacion:{ |
| 862 | ID: true, | 805 | ID: true, |
| 863 | moneda:{ | 806 | moneda:{ |
| 864 | ID: true | 807 | ID: true |
| 865 | } | 808 | } |
| 866 | }, | 809 | }, |
| 867 | flete: true, | 810 | flete: true, |
| 868 | domicilioStamp: true, | 811 | domicilioStamp: true, |
| 869 | domicilio: { | 812 | domicilio: { |
| 870 | id: true | 813 | id: true |
| 871 | }, | 814 | }, |
| 872 | notaPedidoPlazo: [], | 815 | notaPedidoPlazo: [], |
| 873 | articulosNotaPedido: [1], | 816 | articulosNotaPedido: [1], |
| 874 | fechaCarga: true | 817 | fechaCarga: true |
| 875 | }; | 818 | }; |
| 876 | 819 | ||
| 877 | scope.plazosPagos = []; | 820 | scope.plazosPagos = []; |
| 878 | scope.articulosTabla = [1]; | 821 | scope.articulosTabla = [1]; |
| 879 | 822 | ||
| 880 | var promesa = Promise.resolve({ data: 1 }); | 823 | var promesa = Promise.resolve({ data: 1 }); |
| 881 | scope.$broadcast = function() { }; | 824 | scope.$broadcast = function() { }; |
| 882 | 825 | ||
| 883 | //act | 826 | //act |
| 884 | spyOn(crearNotaPedidoService, 'crearNotaPedido').and.returnValue(promesa); | 827 | spyOn(crearNotaPedidoService, 'crearNotaPedido').and.returnValue(promesa); |
| 885 | spyOn(focaSeguimientoService, 'guardarPosicion'); | 828 | spyOn(focaSeguimientoService, 'guardarPosicion'); |
| 886 | spyOn(notaPedidoBusinessService, 'addArticulos'); | 829 | spyOn(notaPedidoBusinessService, 'addArticulos'); |
| 887 | scope.crearNotaPedido(); | 830 | scope.crearNotaPedido(); |
| 888 | //expect | 831 | //expect |
| 889 | 832 | ||
| 890 | promesa.then(function() { | 833 | promesa.then(function() { |
| 891 | expect(focaSeguimientoService.guardarPosicion).toHaveBeenCalled(); | 834 | expect(focaSeguimientoService.guardarPosicion).toHaveBeenCalled(); |
| 892 | expect(notaPedidoBusinessService.addArticulos).toHaveBeenCalled(); | 835 | expect(notaPedidoBusinessService.addArticulos).toHaveBeenCalled(); |
| 893 | done(); | 836 | done(); |
| 894 | }); | 837 | }); |
| 895 | 838 | ||
| 896 | }); | 839 | }); |
| 897 | }); | 840 | }); |
| 898 | }); | 841 | }); |
| 899 | 842 |
src/js/controller.js
| 1 | angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', | 1 | angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
| 2 | [ | 2 | [ |
| 3 | '$scope', | 3 | '$scope', |
| 4 | '$uibModal', | 4 | '$uibModal', |
| 5 | '$location', | 5 | '$location', |
| 6 | '$filter', | 6 | '$filter', |
| 7 | '$timeout', | 7 | '$timeout', |
| 8 | 'crearNotaPedidoService', | 8 | 'crearNotaPedidoService', |
| 9 | 'focaBotoneraLateralService', | 9 | 'focaBotoneraLateralService', |
| 10 | 'focaModalService', | 10 | 'focaModalService', |
| 11 | 'notaPedidoBusinessService', | 11 | 'notaPedidoBusinessService', |
| 12 | '$rootScope', | 12 | '$rootScope', |
| 13 | 'focaSeguimientoService', | 13 | 'focaSeguimientoService', |
| 14 | 'APP', | 14 | 'APP', |
| 15 | 'focaLoginService', | 15 | 'focaLoginService', |
| 16 | '$localStorage', | 16 | '$localStorage', |
| 17 | function( | 17 | function( |
| 18 | $scope, $uibModal, $location, $filter, $timeout, crearNotaPedidoService, | 18 | $scope, $uibModal, $location, $filter, $timeout, crearNotaPedidoService, |
| 19 | focaBotoneraLateralService, focaModalService, notaPedidoBusinessService, | 19 | focaBotoneraLateralService, focaModalService, notaPedidoBusinessService, |
| 20 | $rootScope, focaSeguimientoService, APP, focaLoginService, $localStorage) | 20 | $rootScope, focaSeguimientoService, APP, focaLoginService, $localStorage) |
| 21 | { | 21 | { |
| 22 | config(); | 22 | config(); |
| 23 | 23 | ||
| 24 | function config() { | 24 | function config() { |
| 25 | // PARAMETROS INICIALES PARA FUNCIONAMIENTO DEL PROGRAMA | 25 | // PARAMETROS INICIALES PARA FUNCIONAMIENTO DEL PROGRAMA |
| 26 | $scope.notaPedido = {}; | 26 | $scope.notaPedido = {}; |
| 27 | $scope.isNumber = angular.isNumber; | 27 | $scope.isNumber = angular.isNumber; |
| 28 | $scope.datepickerAbierto = false; | 28 | $scope.datepickerAbierto = false; |
| 29 | $scope.show = false; | 29 | $scope.show = false; |
| 30 | $scope.cargando = true; | 30 | $scope.cargando = true; |
| 31 | $scope.botonera = crearNotaPedidoService.getBotonera(); | ||
| 31 | $scope.puntoVenta = $filter('rellenarDigitos')(0, 4); | 32 | $scope.puntoVenta = $filter('rellenarDigitos')(0, 4); |
| 32 | $scope.comprobante = $filter('rellenarDigitos')(0, 8); | 33 | $scope.comprobante = $filter('rellenarDigitos')(0, 8); |
| 33 | $scope.dateOptions = { | 34 | $scope.dateOptions = { |
| 34 | maxDate: new Date(), | 35 | maxDate: new Date(), |
| 35 | minDate: new Date(2010, 0, 1) | 36 | minDate: new Date(2010, 0, 1) |
| 36 | }; | 37 | }; |
| 37 | 38 | ||
| 38 | //SETEO BOTONERA LATERAL | 39 | //SETEO BOTONERA LATERAL |
| 39 | $timeout(function() { | 40 | $timeout(function() { |
| 40 | focaBotoneraLateralService.showSalir(false); | 41 | focaBotoneraLateralService.showSalir(false); |
| 41 | focaBotoneraLateralService.showPausar(true); | 42 | focaBotoneraLateralService.showPausar(true); |
| 42 | focaBotoneraLateralService.showGuardar(true, $scope.crearNotaPedido); | 43 | focaBotoneraLateralService.showGuardar(true, $scope.crearNotaPedido); |
| 43 | focaBotoneraLateralService.addCustomButton('Salir', salir); | 44 | focaBotoneraLateralService.addCustomButton('Salir', salir); |
| 44 | }); | 45 | }); |
| 45 | 46 | ||
| 46 | // SETEA BOTONERA DE FACTURADOR TENIENDO EN CUENTA SI ESTA SETEADO EL VENDEDOR | 47 | // SETEA BOTONERA DE FACTURADOR TENIENDO EN CUENTA SI ESTA SETEADO EL VENDEDOR |
| 47 | if (APP === 'distribuidor') { | 48 | if (APP === 'distribuidor') { |
| 48 | $scope.idVendedor = focaLoginService.getLoginData().vendedorCobrador; | 49 | $scope.idVendedor = focaLoginService.getLoginData().vendedorCobrador; |
| 49 | $scope.botonera = crearNotaPedidoService.getBotonera($scope.idVendedor); | ||
| 50 | } else { | ||
| 51 | $scope.botonera = crearNotaPedidoService.getBotonera(); | ||
| 52 | } | 50 | } |
| 53 | 51 | ||
| 54 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' | 52 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' |
| 55 | crearNotaPedidoService.getCotizacionByIdMoneda(1).then(function(res) { | 53 | crearNotaPedidoService.getCotizacionByIdMoneda(1).then(function(res) { |
| 56 | var monedaPorDefecto = res.data[0]; | 54 | var monedaPorDefecto = res.data[0]; |
| 57 | 55 | ||
| 58 | $scope.notaPedido.cotizacion = Object.assign( | 56 | $scope.notaPedido.cotizacion = Object.assign( |
| 59 | {moneda: monedaPorDefecto}, | 57 | {moneda: monedaPorDefecto}, |
| 60 | monedaPorDefecto.cotizaciones[0] | 58 | monedaPorDefecto.cotizaciones[0] |
| 61 | ); | 59 | ); |
| 62 | $scope.inicial.cotizacion = $scope.notaPedido.cotizacion; | 60 | $scope.inicial.cotizacion = $scope.notaPedido.cotizacion; |
| 63 | }); | 61 | }); |
| 64 | 62 | ||
| 65 | init(); | 63 | init(); |
| 66 | $timeout(function() {getLSNotaPedido();}); | 64 | $timeout(function() {getLSNotaPedido();}); |
| 67 | } | 65 | } |
| 68 | 66 | ||
| 69 | function init() { | 67 | function init() { |
| 70 | $scope.$broadcast('cleanCabecera'); | 68 | $scope.$broadcast('cleanCabecera'); |
| 71 | 69 | ||
| 72 | $scope.notaPedido = { | 70 | $scope.notaPedido = { |
| 73 | id: 0, | 71 | id: 0, |
| 74 | cliente: {}, | 72 | cliente: {}, |
| 75 | proveedor: {}, | 73 | proveedor: {}, |
| 76 | domicilio: {dom: ''}, | 74 | domicilio: {dom: ''}, |
| 77 | vendedor: {}, | 75 | vendedor: {}, |
| 78 | fechaCarga: new Date(), | 76 | fechaCarga: new Date(), |
| 79 | cotizacion: {}, | 77 | cotizacion: {}, |
| 80 | articulosNotaPedido: [], | 78 | articulosNotaPedido: [], |
| 81 | notaPedidoPlazo: [] | 79 | notaPedidoPlazo: [] |
| 82 | }; | 80 | }; |
| 83 | $scope.idLista = undefined; | 81 | $scope.idLista = undefined; |
| 84 | 82 | ||
| 85 | crearNotaPedidoService.getNumeroNotaPedido().then( | 83 | crearNotaPedidoService.getNumeroNotaPedido().then( |
| 86 | function(res) { | 84 | function(res) { |
| 87 | $scope.puntoVenta = $filter('rellenarDigitos')( | 85 | $scope.puntoVenta = $filter('rellenarDigitos')( |
| 88 | res.data.sucursal, 4 | 86 | res.data.sucursal, 4 |
| 89 | ); | 87 | ); |
| 90 | 88 | ||
| 91 | $scope.comprobante = $filter('rellenarDigitos')( | 89 | $scope.comprobante = $filter('rellenarDigitos')( |
| 92 | res.data.numeroNotaPedido, 8 | 90 | res.data.numeroNotaPedido, 8 |
| 93 | ); | 91 | ); |
| 94 | }, | 92 | }, |
| 95 | function(err) { | 93 | function(err) { |
| 96 | focaModalService.alert('La terminal no esta configurada correctamente'); | 94 | focaModalService.alert('La terminal no esta configurada correctamente'); |
| 97 | console.info(err); | 95 | console.info(err); |
| 98 | } | 96 | } |
| 99 | ); | 97 | ); |
| 100 | 98 | ||
| 101 | if (APP === 'distribuidor') { | 99 | if (APP === 'distribuidor') { |
| 102 | crearNotaPedidoService.getVendedorById($scope.idVendedor).then( | 100 | crearNotaPedidoService.getVendedorById($scope.idVendedor).then( |
| 103 | function(res) { | 101 | function(res) { |
| 104 | var vendedor = res.data; | 102 | var vendedor = res.data; |
| 105 | $scope.$broadcast('addCabecera', { | 103 | $scope.$broadcast('addCabecera', { |
| 106 | label: 'Vendedor:', | 104 | label: 'Vendedor:', |
| 107 | valor: $filter('rellenarDigitos')(vendedor.NUM, 3) + ' - ' + | 105 | valor: $filter('rellenarDigitos')(vendedor.NUM, 3) + ' - ' + |
| 108 | vendedor.NOM | 106 | vendedor.NOM |
| 109 | }); | 107 | }); |
| 110 | 108 | ||
| 111 | $scope.notaPedido.vendedor = vendedor; | 109 | $scope.notaPedido.vendedor = vendedor; |
| 112 | $scope.inicial.notaPedido.vendedor =$scope.notaPedido.vendedor; | 110 | $scope.inicial.notaPedido.vendedor =$scope.notaPedido.vendedor; |
| 113 | } | 111 | } |
| 114 | ); | 112 | ); |
| 115 | } | 113 | } |
| 116 | 114 | ||
| 117 | $scope.inicial = angular.copy($scope.notaPedido); | 115 | $scope.inicial = angular.copy($scope.notaPedido); |
| 118 | } | 116 | } |
| 119 | 117 | ||
| 120 | $scope.$watch('notaPedido', function(newValue, oldValue) { | 118 | $scope.$watch('notaPedido', function(newValue) { |
| 121 | focaBotoneraLateralService.setPausarData({ | 119 | focaBotoneraLateralService.setPausarData({ |
| 122 | label: 'notaPedido', | 120 | label: 'notaPedido', |
| 123 | val: newValue | 121 | val: newValue |
| 124 | }); | 122 | }); |
| 125 | }, true); | 123 | }, true); |
| 126 | 124 | ||
| 127 | $scope.crearNotaPedido = function() { | 125 | $scope.crearNotaPedido = function() { |
| 128 | if (!$scope.notaPedido.vendedor.id) { | 126 | if (!$scope.notaPedido.cliente.COD) { |
| 129 | focaModalService.alert('Ingrese Vendedor'); | ||
| 130 | return; | ||
| 131 | } else if (!$scope.notaPedido.cliente.COD) { | ||
| 132 | focaModalService.alert('Ingrese Cliente'); | 127 | focaModalService.alert('Ingrese Cliente'); |
| 133 | return; | 128 | return; |
| 134 | } else if (!$scope.notaPedido.proveedor.COD) { | 129 | } else if (!$scope.notaPedido.proveedor.COD) { |
| 135 | focaModalService.alert('Ingrese Proveedor'); | 130 | focaModalService.alert('Ingrese Proveedor'); |
| 136 | return; | 131 | return; |
| 137 | } else if (!$scope.notaPedido.cotizacion.ID) { | 132 | } else if (!$scope.notaPedido.cotizacion.ID) { |
| 138 | focaModalService.alert('Ingrese Cotización'); | 133 | focaModalService.alert('Ingrese Cotización'); |
| 139 | return; | 134 | return; |
| 140 | } else if (!$scope.notaPedido.cotizacion.moneda.ID) { | 135 | } else if (!$scope.notaPedido.cotizacion.moneda.ID) { |
| 141 | focaModalService.alert('Ingrese Moneda'); | 136 | focaModalService.alert('Ingrese Moneda'); |
| 142 | return; | 137 | return; |
| 143 | } else if (!$scope.notaPedido.notaPedidoPlazo) { | 138 | } else if (!$scope.notaPedido.notaPedidoPlazo) { |
| 144 | focaModalService.alert('Ingrese Precios y Condiciones'); | 139 | focaModalService.alert('Ingrese Precios y Condiciones'); |
| 145 | return; | 140 | return; |
| 146 | } else if ( | 141 | } else if ( |
| 147 | $scope.notaPedido.flete === undefined || $scope.notaPedido.flete === null) | 142 | $scope.notaPedido.flete === undefined || $scope.notaPedido.flete === null) |
| 148 | { | 143 | { |
| 149 | focaModalService.alert('Ingrese Flete'); | 144 | focaModalService.alert('Ingrese Flete'); |
| 150 | return; | 145 | return; |
| 151 | } else if (!$scope.notaPedido.domicilioStamp) {//TODO validar domicilio correcto | 146 | } else if (!$scope.notaPedido.domicilioStamp) {//TODO validar domicilio correcto |
| 152 | focaModalService.alert('Ingrese Domicilio'); | 147 | focaModalService.alert('Ingrese Domicilio'); |
| 153 | return; | 148 | return; |
| 154 | } else if ($scope.notaPedido.articulosNotaPedido.length === 0) { | 149 | } else if ($scope.notaPedido.articulosNotaPedido.length === 0) { |
| 155 | focaModalService.alert('Debe cargar al menos un articulo'); | 150 | focaModalService.alert('Debe cargar al menos un articulo'); |
| 156 | return; | 151 | return; |
| 157 | } | 152 | } |
| 158 | focaBotoneraLateralService.startGuardar(); | 153 | focaBotoneraLateralService.startGuardar(); |
| 159 | $scope.saveLoading = true; | 154 | $scope.saveLoading = true; |
| 160 | var notaPedido = { | 155 | var notaPedido = { |
| 161 | id: $scope.notaPedido.id, | 156 | id: $scope.notaPedido.id, |
| 162 | fechaCarga: new Date($scope.notaPedido.fechaCarga).toISOString().slice(0, 19).replace('T', ' '), | 157 | fechaCarga: new Date($scope.notaPedido.fechaCarga) |
| 158 | .toISOString().slice(0, 19).replace('T', ' '), | ||
| 163 | idVendedor: $scope.notaPedido.vendedor.id, | 159 | idVendedor: $scope.notaPedido.vendedor.id, |
| 164 | idCliente: $scope.notaPedido.cliente.COD, | 160 | idCliente: $scope.notaPedido.cliente.COD, |
| 165 | nombreCliente: $scope.notaPedido.cliente.NOM, | 161 | nombreCliente: $scope.notaPedido.cliente.NOM, |
| 166 | cuitCliente: $scope.notaPedido.cliente.CUIT, | 162 | cuitCliente: $scope.notaPedido.cliente.CUIT, |
| 167 | idProveedor: $scope.notaPedido.proveedor.COD, | 163 | idProveedor: $scope.notaPedido.proveedor.COD, |
| 168 | idDomicilio: $scope.notaPedido.domicilio.id, | 164 | idDomicilio: $scope.notaPedido.domicilio.id, |
| 169 | idCotizacion: $scope.notaPedido.cotizacion.ID, | 165 | idCotizacion: $scope.notaPedido.cotizacion.ID, |
| 170 | idPrecioCondicion: $scope.notaPedido.idPrecioCondicion, | 166 | idPrecioCondicion: $scope.notaPedido.idPrecioCondicion, |
| 171 | cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, | 167 | cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, |
| 172 | flete: $scope.notaPedido.flete, | 168 | flete: $scope.notaPedido.flete, |
| 173 | fob: $scope.notaPedido.fob, | 169 | fob: $scope.notaPedido.fob, |
| 174 | bomba: $scope.notaPedido.bomba, | 170 | bomba: $scope.notaPedido.bomba, |
| 175 | kilometros: $scope.notaPedido.kilometros, | 171 | kilometros: $scope.notaPedido.kilometros, |
| 176 | domicilioStamp: $scope.notaPedido.domicilioStamp, | 172 | domicilioStamp: $scope.notaPedido.domicilioStamp, |
| 177 | observaciones: $scope.notaPedido.observaciones, | 173 | observaciones: $scope.notaPedido.observaciones, |
| 178 | estado: 0, | 174 | estado: 0, |
| 179 | total: $scope.getTotal() | 175 | total: $scope.getTotal() |
| 180 | }; | 176 | }; |
| 181 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( | 177 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( |
| 182 | function(data) { | 178 | function(data) { |
| 183 | // Al guardar los datos de la nota de pedido logueamos la | 179 | // Al guardar los datos de la nota de pedido logueamos la |
| 184 | // actividad para su seguimiento. | 180 | // actividad para su seguimiento. |
| 185 | //TODO: GUARDAR POSISIONAMIENTO AL EDITAR? | 181 | //TODO: GUARDAR POSISIONAMIENTO AL EDITAR? |
| 186 | focaSeguimientoService.guardarPosicion( | 182 | focaSeguimientoService.guardarPosicion( |
| 187 | 'Nota de pedido', | 183 | 'Nota de pedido', |
| 188 | data.data.id, | 184 | data.data.id, |
| 189 | '' | 185 | '' |
| 190 | ); | 186 | ); |
| 191 | notaPedidoBusinessService.addArticulos( | 187 | notaPedidoBusinessService.addArticulos( |
| 192 | $scope.notaPedido.articulosNotaPedido, | 188 | $scope.notaPedido.articulosNotaPedido, |
| 193 | data.data.id, $scope.notaPedido.cotizacion.VENDEDOR); | 189 | data.data.id, $scope.notaPedido.cotizacion.VENDEDOR); |
| 194 | 190 | ||
| 195 | if ($scope.notaPedido.notaPedidoPuntoDescarga) { | 191 | if ($scope.notaPedido.notaPedidoPuntoDescarga) { |
| 196 | notaPedidoBusinessService.addPuntosDescarga(data.data.id, | 192 | notaPedidoBusinessService.addPuntosDescarga(data.data.id, |
| 197 | $scope.notaPedido.notaPedidoPuntoDescarga); | 193 | $scope.notaPedido.notaPedidoPuntoDescarga); |
| 198 | } | 194 | } |
| 199 | 195 | ||
| 200 | var plazos = $scope.notaPedido.notaPedidoPlazo; | 196 | var plazos = $scope.notaPedido.notaPedidoPlazo; |
| 201 | var plazosACrear = []; | 197 | var plazosACrear = []; |
| 202 | plazos.forEach(function(plazo) { | 198 | plazos.forEach(function(plazo) { |
| 203 | plazosACrear.push({ | 199 | plazosACrear.push({ |
| 204 | idNotaPedido: data.data.id, | 200 | idNotaPedido: data.data.id, |
| 205 | dias: plazo.dias | 201 | dias: plazo.dias |
| 206 | }); | 202 | }); |
| 207 | }); | 203 | }); |
| 208 | 204 | ||
| 209 | if (plazosACrear.length) { | 205 | if (plazosACrear.length) { |
| 210 | crearNotaPedidoService.crearPlazosParaNotaPedido(plazosACrear); | 206 | crearNotaPedidoService.crearPlazosParaNotaPedido(plazosACrear); |
| 211 | } | 207 | } |
| 212 | 208 | ||
| 213 | notaPedidoBusinessService.addEstado(data.data.id, | 209 | notaPedidoBusinessService.addEstado(data.data.id, |
| 214 | $scope.notaPedido.vendedor.id); | 210 | $scope.notaPedido.vendedor.id); |
| 215 | 211 | ||
| 216 | focaBotoneraLateralService.endGuardar(true); | 212 | focaBotoneraLateralService.endGuardar(true); |
| 217 | $scope.saveLoading = false; | 213 | $scope.saveLoading = false; |
| 218 | 214 | ||
| 219 | init(); | 215 | init(); |
| 220 | }, function(error) { | 216 | }, function(error) { |
| 221 | focaModalService.alert('Hubo un error al crear la nota de pedido'); | 217 | focaModalService.alert('Hubo un error al crear la nota de pedido'); |
| 222 | focaBotoneraLateralService.endGuardar(); | 218 | focaBotoneraLateralService.endGuardar(); |
| 223 | $scope.saveLoading = false; | 219 | $scope.saveLoading = false; |
| 224 | console.info(error); | 220 | console.info(error); |
| 225 | } | 221 | } |
| 226 | ); | 222 | ); |
| 227 | }; | 223 | }; |
| 228 | 224 | ||
| 229 | $scope.seleccionarNotaPedido = function() { | 225 | $scope.seleccionarNotaPedido = function() { |
| 230 | var modalInstance = $uibModal.open( | 226 | var modalInstance = $uibModal.open( |
| 231 | { | 227 | { |
| 232 | ariaLabelledBy: 'Busqueda de Nota de Pedido', | 228 | ariaLabelledBy: 'Busqueda de Nota de Pedido', |
| 233 | templateUrl: 'foca-modal-nota-pedido.html', | 229 | templateUrl: 'foca-modal-nota-pedido.html', |
| 234 | controller: 'focaModalNotaPedidoController', | 230 | controller: 'focaModalNotaPedidoController', |
| 235 | size: 'lg', | 231 | size: 'lg', |
| 236 | resolve: { | 232 | resolve: { |
| 237 | usadoPor: function() {return 'notaPedido';}, | 233 | usadoPor: function() {return 'notaPedido';}, |
| 238 | idVendedor: function() { | 234 | idVendedor: function() { |
| 239 | if(APP === 'distribuidor') | 235 | if (APP === 'distribuidor') |
| 240 | return $scope.notaPedido.vendedor.id; | 236 | return $scope.notaPedido.vendedor.id; |
| 241 | else | 237 | else |
| 242 | return null; | 238 | return null; |
| 243 | } | 239 | } |
| 244 | } | 240 | } |
| 245 | } | 241 | } |
| 246 | ); | 242 | ); |
| 247 | modalInstance.result.then(setearNotaPedido); | 243 | modalInstance.result.then(setearNotaPedido); |
| 248 | }; | 244 | }; |
| 249 | 245 | ||
| 250 | $scope.seleccionarProductos = function() { | 246 | $scope.seleccionarProductos = function() { |
| 251 | if ($scope.idLista === undefined) { | 247 | if ($scope.idLista === undefined) { |
| 252 | focaModalService.alert( | 248 | focaModalService.alert( |
| 253 | 'Primero seleccione una lista de precio y condicion'); | 249 | 'Primero seleccione una lista de precio y condicion'); |
| 254 | return; | 250 | return; |
| 255 | } | 251 | } |
| 256 | var modalInstance = $uibModal.open( | 252 | var modalInstance = $uibModal.open( |
| 257 | { | 253 | { |
| 258 | ariaLabelledBy: 'Busqueda de Productos', | 254 | ariaLabelledBy: 'Busqueda de Productos', |
| 259 | templateUrl: 'modal-busqueda-productos.html', | 255 | templateUrl: 'modal-busqueda-productos.html', |
| 260 | controller: 'modalBusquedaProductosCtrl', | 256 | controller: 'modalBusquedaProductosCtrl', |
| 261 | resolve: { | 257 | resolve: { |
| 262 | parametroProducto: { | 258 | parametroProducto: { |
| 263 | idLista: $scope.idLista, | 259 | idLista: $scope.idLista, |
| 264 | cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, | 260 | cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, |
| 265 | simbolo: $scope.notaPedido.cotizacion.moneda.SIMBOLO | 261 | simbolo: $scope.notaPedido.cotizacion.moneda.SIMBOLO |
| 266 | } | 262 | } |
| 267 | }, | 263 | }, |
| 268 | size: 'lg' | 264 | size: 'lg' |
| 269 | } | 265 | } |
| 270 | ); | 266 | ); |
| 271 | modalInstance.result.then( | 267 | modalInstance.result.then( |
| 272 | function(producto) { | 268 | function(producto) { |
| 273 | var newArt = | 269 | var newArt = |
| 274 | { | 270 | { |
| 275 | id: 0, | 271 | id: 0, |
| 276 | codigo: producto.codigo, | 272 | codigo: producto.codigo, |
| 277 | sector: producto.sector, | 273 | sector: producto.sector, |
| 278 | sectorCodigo: producto.sector + '-' + producto.codigo, | 274 | sectorCodigo: producto.sector + '-' + producto.codigo, |
| 279 | descripcion: producto.descripcion, | 275 | descripcion: producto.descripcion, |
| 280 | item: $scope.notaPedido.articulosNotaPedido.length + 1, | 276 | item: $scope.notaPedido.articulosNotaPedido.length + 1, |
| 281 | nombre: producto.descripcion, | 277 | nombre: producto.descripcion, |
| 282 | precio: parseFloat(producto.precio.toFixed(4)), | 278 | precio: parseFloat(producto.precio.toFixed(4)), |
| 283 | costoUnitario: producto.costo, | 279 | costoUnitario: producto.costo, |
| 284 | editCantidad: false, | 280 | editCantidad: false, |
| 285 | editPrecio: false, | 281 | editPrecio: false, |
| 286 | rubro: producto.CodRub, | 282 | rubro: producto.CodRub, |
| 287 | exentoUnitario: producto.precio, | 283 | exentoUnitario: producto.precio, |
| 288 | ivaUnitario: producto.IMPIVA, | 284 | ivaUnitario: producto.IMPIVA, |
| 289 | impuestoInternoUnitario: producto.ImpInt, | 285 | impuestoInternoUnitario: producto.ImpInt, |
| 290 | impuestoInterno1Unitario: producto.ImpInt2, | 286 | impuestoInterno1Unitario: producto.ImpInt2, |
| 291 | impuestoInterno2Unitario: producto.ImpInt3, | 287 | impuestoInterno2Unitario: producto.ImpInt3, |
| 292 | precioLista: producto.precio, | 288 | precioLista: producto.precio, |
| 293 | combustible: 1, | 289 | combustible: 1, |
| 294 | facturado: 0, | 290 | facturado: 0, |
| 295 | idArticulo: producto.id | 291 | idArticulo: producto.id |
| 296 | }; | 292 | }; |
| 297 | $scope.articuloACargar = newArt; | 293 | $scope.articuloACargar = newArt; |
| 298 | $scope.cargando = false; | 294 | $scope.cargando = false; |
| 299 | }, function() { | 295 | }, function() { |
| 300 | // funcion ejecutada cuando se cancela el modal | 296 | // funcion ejecutada cuando se cancela el modal |
| 301 | } | 297 | } |
| 302 | ); | 298 | ); |
| 303 | }; | 299 | }; |
| 304 | 300 | ||
| 305 | $scope.seleccionarPuntosDeDescarga = function() { | 301 | $scope.seleccionarPuntosDeDescarga = function() { |
| 306 | if(!$scope.notaPedido.cliente.COD || !$scope.notaPedido.domicilio.id) { | 302 | if (!$scope.notaPedido.cliente.COD || !$scope.notaPedido.domicilio.id) { |
| 307 | focaModalService.alert('Primero seleccione un cliente y un domicilio'); | 303 | focaModalService.alert('Primero seleccione un cliente y un domicilio'); |
| 308 | return; | 304 | return; |
| 309 | }else { | 305 | } else { |
| 310 | var modalInstance = $uibModal.open( | 306 | var modalInstance = $uibModal.open( |
| 311 | { | 307 | { |
| 312 | ariaLabelledBy: 'Búsqueda de Puntos de descarga', | 308 | ariaLabelledBy: 'Búsqueda de Puntos de descarga', |
| 313 | templateUrl: 'modal-punto-descarga.html', | 309 | templateUrl: 'modal-punto-descarga.html', |
| 314 | controller: 'focaModalPuntoDescargaController', | 310 | controller: 'focaModalPuntoDescargaController', |
| 315 | size: 'lg', | 311 | size: 'lg', |
| 316 | resolve: { | 312 | resolve: { |
| 317 | filters: { | 313 | filters: { |
| 318 | idDomicilio: $scope.notaPedido.domicilio.id, | 314 | idDomicilio: $scope.notaPedido.domicilio.id, |
| 319 | idCliente: $scope.notaPedido.cliente.COD, | 315 | idCliente: $scope.notaPedido.cliente.COD, |
| 320 | articulos: $scope.notaPedido.articulosNotaPedido, | 316 | articulos: $scope.notaPedido.articulosNotaPedido, |
| 321 | puntosDescarga: $scope.notaPedido.notaPedidoPuntoDescarga | 317 | puntosDescarga: $scope.notaPedido.notaPedidoPuntoDescarga |
| 322 | } | 318 | } |
| 323 | } | 319 | } |
| 324 | } | 320 | } |
| 325 | ); | 321 | ); |
| 326 | modalInstance.result.then( | 322 | modalInstance.result.then( |
| 327 | function(puntosDescarga) { | 323 | function(puntosDescarga) { |
| 328 | $scope.notaPedido.notaPedidoPuntoDescarga = puntosDescarga; | 324 | $scope.notaPedido.notaPedidoPuntoDescarga = puntosDescarga; |
| 329 | 325 | ||
| 330 | //AGREGO PUNTOS DE DESCARGA A CABECERA | 326 | //AGREGO PUNTOS DE DESCARGA A CABECERA |
| 331 | var puntosStamp = ''; | 327 | var puntosStamp = ''; |
| 332 | puntosDescarga.forEach(function(punto, idx, arr) { | 328 | puntosDescarga.forEach(function(punto, idx, arr) { |
| 333 | puntosStamp += punto.descripcion; | 329 | puntosStamp += punto.descripcion; |
| 334 | if((idx + 1) !== arr.length) puntosStamp += ', '; | 330 | if ((idx + 1) !== arr.length) puntosStamp += ', '; |
| 335 | }); | 331 | }); |
| 336 | 332 | ||
| 337 | $scope.$broadcast('addCabecera', { | 333 | $scope.$broadcast('addCabecera', { |
| 338 | label: 'Puntos de descarga:', | 334 | label: 'Puntos de descarga:', |
| 339 | valor: puntosStamp | 335 | valor: puntosStamp |
| 340 | }); | 336 | }); |
| 341 | }, function() { | 337 | }, function() { |
| 342 | $scope.abrirModalDomicilios($scope.cliente); | 338 | $scope.abrirModalDomicilios($scope.cliente); |
| 343 | } | 339 | } |
| 344 | ); | 340 | ); |
| 345 | } | 341 | } |
| 346 | }; | 342 | }; |
| 347 | 343 | ||
| 348 | $scope.seleccionarVendedor = function() { | 344 | $scope.seleccionarTransportista = function() { |
| 349 | if(validarNotaRemitada()) { | 345 | $scope.seleccionarProveedor(function() { |
| 346 | if (validarNotaRemitada()) { | ||
| 347 | var modalInstance = $uibModal.open( | ||
| 348 | { | ||
| 349 | ariaLabelledBy: 'Busqueda de Flete', | ||
| 350 | templateUrl: 'modal-flete.html', | ||
| 351 | controller: 'focaModalFleteController', | ||
| 352 | size: 'lg', | ||
| 353 | resolve: { | ||
| 354 | parametrosFlete: | ||
| 355 | function() { | ||
| 356 | return { | ||
| 357 | flete: $scope.notaPedido.fob ? 'FOB' : | ||
| 358 | ( $scope.notaPedido.flete ? '1' : | ||
| 359 | ($scope.notaPedido.flete === undefined ? | ||
| 360 | null : '0')), | ||
| 361 | bomba: $scope.notaPedido.bomba ? '1' : | ||
| 362 | ($scope.notaPedido.bomba === undefined ? | ||
| 363 | null : '0'), | ||
| 364 | kilometros: $scope.notaPedido.kilometros | ||
| 365 | }; | ||
| 366 | } | ||
| 367 | } | ||
| 368 | } | ||
| 369 | ); | ||
| 370 | modalInstance.result.then( | ||
| 371 | function(datos) { | ||
| 372 | $scope.notaPedido.flete = datos.flete; | ||
| 373 | $scope.notaPedido.fob = datos.FOB; | ||
| 374 | $scope.notaPedido.bomba = datos.bomba; | ||
| 375 | $scope.notaPedido.kilometros = datos.kilometros; | ||
| 376 | $scope.$broadcast('addCabecera', { | ||
| 377 | label: 'Flete:', | ||
| 378 | valor: datos.FOB ? 'FOB' : (datos.flete ? 'Si' : 'No') | ||
| 379 | }); | ||
| 380 | if (datos.flete) { | ||
| 381 | $scope.$broadcast('addCabecera', { | ||
| 382 | label: 'Bomba:', | ||
| 383 | valor: datos.bomba ? 'Si' : 'No' | ||
| 384 | }); | ||
| 385 | $scope.$broadcast('addCabecera', { | ||
| 386 | label: 'Kilometros:', | ||
| 387 | valor: datos.kilometros | ||
| 388 | }); | ||
| 389 | } else { | ||
| 390 | $scope.$broadcast('removeCabecera', 'Bomba:'); | ||
| 391 | $scope.$broadcast('removeCabecera', 'Kilometros:'); | ||
| 392 | $scope.notaPedido.bomba = false; | ||
| 393 | $scope.notaPedido.kilometros = null; | ||
| 394 | } | ||
| 395 | }, function() { | ||
| 396 | $scope.seleccionarTransportista(); | ||
| 397 | } | ||
| 398 | ); | ||
| 399 | } | ||
| 400 | }); | ||
| 401 | }; | ||
| 402 | |||
| 403 | $scope.seleccionarVendedor = function(callback, ocultarVendedor) { | ||
| 404 | if (APP === 'distribuidor' || ocultarVendedor) { | ||
| 405 | callback(); | ||
| 406 | return; | ||
| 407 | } | ||
| 408 | |||
| 409 | if (validarNotaRemitada()) { | ||
| 350 | var parametrosModal = { | 410 | var parametrosModal = { |
| 351 | titulo: 'Búsqueda vendedores', | 411 | titulo: 'Búsqueda vendedores', |
| 352 | query: '/vendedor', | 412 | query: '/vendedor', |
| 353 | columnas: [ | 413 | columnas: [ |
| 354 | { | 414 | { |
| 355 | propiedad: 'NUM', | 415 | propiedad: 'NUM', |
| 356 | nombre: 'Código', | 416 | nombre: 'Código', |
| 357 | filtro: { | 417 | filtro: { |
| 358 | nombre: 'rellenarDigitos', | 418 | nombre: 'rellenarDigitos', |
| 359 | parametro: 3 | 419 | parametro: 3 |
| 360 | } | 420 | } |
| 361 | }, | 421 | }, |
| 362 | { | 422 | { |
| 363 | propiedad: 'NOM', | 423 | propiedad: 'NOM', |
| 364 | nombre: 'Nombre' | 424 | nombre: 'Nombre' |
| 365 | } | 425 | } |
| 366 | ], | 426 | ], |
| 367 | size: 'md' | 427 | size: 'md' |
| 368 | }; | 428 | }; |
| 369 | focaModalService.modal(parametrosModal).then( | 429 | focaModalService.modal(parametrosModal).then( |
| 370 | function(vendedor) { | 430 | function(vendedor) { |
| 371 | $scope.$broadcast('addCabecera', { | 431 | $scope.$broadcast('addCabecera', { |
| 372 | label: 'Vendedor:', | 432 | label: 'Vendedor:', |
| 373 | valor: $filter('rellenarDigitos')(vendedor.NUM, 3) + ' - ' + | 433 | valor: $filter('rellenarDigitos')(vendedor.NUM, 3) + ' - ' + |
| 374 | vendedor.NOM | 434 | vendedor.NOM |
| 375 | }); | 435 | }); |
| 376 | $scope.notaPedido.vendedor = vendedor; | 436 | $scope.notaPedido.vendedor = vendedor; |
| 377 | }, function() { | 437 | deleteCliente(); |
| 378 | 438 | callback(); | |
| 379 | } | 439 | }, function() {} |
| 380 | ); | 440 | ); |
| 381 | } | 441 | } |
| 382 | }; | 442 | }; |
| 383 | 443 | ||
| 384 | $scope.seleccionarProveedor = function() { | 444 | $scope.seleccionarCliente = function(ocultarVendedor) { |
| 385 | if(validarNotaRemitada()) { | 445 | $scope.seleccionarVendedor(function() { |
| 446 | if (validarNotaRemitada()) { | ||
| 447 | var modalInstance = $uibModal.open( | ||
| 448 | { | ||
| 449 | ariaLabelledBy: 'Busqueda de Cliente', | ||
| 450 | templateUrl: 'foca-busqueda-cliente-modal.html', | ||
| 451 | controller: 'focaBusquedaClienteModalController', | ||
| 452 | resolve: { | ||
| 453 | vendedor: function() { return $scope.notaPedido.vendedor; }, | ||
| 454 | cobrador: function() { return null; } | ||
| 455 | }, | ||
| 456 | size: 'lg' | ||
| 457 | } | ||
| 458 | ); | ||
| 459 | modalInstance.result.then( | ||
| 460 | function(cliente) { | ||
| 461 | $scope.abrirModalDomicilios(cliente); | ||
| 462 | $scope.cliente = cliente; | ||
| 463 | }, function() { | ||
| 464 | if (APP !== 'distribuidor') $scope.seleccionarCliente(); | ||
| 465 | } | ||
| 466 | ); | ||
| 467 | } | ||
| 468 | }, ocultarVendedor); | ||
| 469 | }; | ||
| 470 | |||
| 471 | $scope.seleccionarProveedor = function(callback) { | ||
| 472 | if (validarNotaRemitada()) { | ||
| 386 | var parametrosModal = { | 473 | var parametrosModal = { |
| 387 | titulo: 'Búsqueda de Proveedor', | 474 | titulo: 'Búsqueda de Proveedor', |
| 388 | query: '/proveedor', | 475 | query: '/proveedor', |
| 389 | columnas: [ | 476 | columnas: [ |
| 390 | { | 477 | { |
| 391 | nombre: 'Código', | 478 | nombre: 'Código', |
| 392 | propiedad: 'COD', | 479 | propiedad: 'COD', |
| 393 | filtro: { | 480 | filtro: { |
| 394 | nombre: 'rellenarDigitos', | 481 | nombre: 'rellenarDigitos', |
| 395 | parametro: 5 | 482 | parametro: 5 |
| 396 | } | 483 | } |
| 397 | }, | 484 | }, |
| 398 | { | 485 | { |
| 399 | nombre: 'Nombre', | 486 | nombre: 'Nombre', |
| 400 | propiedad: 'NOM' | 487 | propiedad: 'NOM' |
| 401 | }, | 488 | }, |
| 402 | { | 489 | { |
| 403 | nombre: 'CUIT', | 490 | nombre: 'CUIT', |
| 404 | propiedad: 'CUIT' | 491 | propiedad: 'CUIT' |
| 405 | } | 492 | } |
| 406 | ], | 493 | ], |
| 407 | tipo: 'POST', | 494 | tipo: 'POST', |
| 408 | json: {razonCuitCod: ''} | 495 | json: {razonCuitCod: ''} |
| 409 | }; | 496 | }; |
| 410 | focaModalService.modal(parametrosModal).then( | 497 | focaModalService.modal(parametrosModal).then( |
| 411 | function(proveedor) { | 498 | function(proveedor) { |
| 412 | $scope.notaPedido.proveedor = proveedor; | 499 | $scope.notaPedido.proveedor = proveedor; |
| 413 | $scope.$broadcast('addCabecera', { | 500 | $scope.$broadcast('addCabecera', { |
| 414 | label: 'Proveedor:', | 501 | label: 'Proveedor:', |
| 415 | valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + | 502 | valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + |
| 416 | proveedor.NOM | 503 | proveedor.NOM |
| 417 | }); | 504 | }); |
| 505 | callback(); | ||
| 418 | }, function() { | 506 | }, function() { |
| 419 | 507 | ||
| 420 | } | 508 | } |
| 421 | ); | 509 | ); |
| 422 | } | 510 | } |
| 423 | }; | 511 | }; |
| 424 | 512 | ||
| 425 | $scope.seleccionarCliente = function() { | ||
| 426 | if(!$scope.notaPedido.vendedor.NUM) { | ||
| 427 | focaModalService.alert('Primero seleccione un vendedor'); | ||
| 428 | return; | ||
| 429 | } | ||
| 430 | if(validarNotaRemitada()) { | ||
| 431 | var modalInstance = $uibModal.open( | ||
| 432 | { | ||
| 433 | ariaLabelledBy: 'Busqueda de Cliente', | ||
| 434 | templateUrl: 'foca-busqueda-cliente-modal.html', | ||
| 435 | controller: 'focaBusquedaClienteModalController', | ||
| 436 | resolve: { | ||
| 437 | vendedor: function() { return $scope.notaPedido.vendedor; } | ||
| 438 | }, | ||
| 439 | size: 'lg' | ||
| 440 | } | ||
| 441 | ); | ||
| 442 | modalInstance.result.then( | ||
| 443 | function(cliente) { | ||
| 444 | $scope.abrirModalDomicilios(cliente); | ||
| 445 | $scope.cliente = cliente; | ||
| 446 | }, function() {} | ||
| 447 | ); | ||
| 448 | } | ||
| 449 | }; | ||
| 450 | |||
| 451 | $scope.abrirModalDomicilios = function(cliente) { | 513 | $scope.abrirModalDomicilios = function(cliente) { |
| 452 | var modalInstanceDomicilio = $uibModal.open( | 514 | var modalInstanceDomicilio = $uibModal.open( |
| 453 | { | 515 | { |
| 454 | ariaLabelledBy: 'Busqueda de Domicilios', | 516 | ariaLabelledBy: 'Busqueda de Domicilios', |
| 455 | templateUrl: 'modal-domicilio.html', | 517 | templateUrl: 'modal-domicilio.html', |
| 456 | controller: 'focaModalDomicilioController', | 518 | controller: 'focaModalDomicilioController', |
| 457 | resolve: { | 519 | resolve: { |
| 458 | idCliente: function() { return cliente.cod; }, | 520 | idCliente: function() { return cliente.cod; }, |
| 459 | esNuevo: function() { return cliente.esNuevo; } | 521 | esNuevo: function() { return cliente.esNuevo; } |
| 460 | }, | 522 | }, |
| 461 | size: 'lg', | 523 | size: 'lg', |
| 462 | } | 524 | } |
| 463 | ); | 525 | ); |
| 464 | modalInstanceDomicilio.result.then( | 526 | modalInstanceDomicilio.result.then( |
| 465 | function(domicilio) { | 527 | function(domicilio) { |
| 466 | $scope.notaPedido.domicilio = domicilio; | 528 | $scope.notaPedido.domicilio = domicilio; |
| 467 | $scope.notaPedido.cliente = { | 529 | $scope.notaPedido.cliente = { |
| 468 | COD: cliente.cod, | 530 | COD: cliente.cod, |
| 469 | CUIT: cliente.cuit, | 531 | CUIT: cliente.cuit, |
| 470 | NOM: cliente.nom | 532 | NOM: cliente.nom, |
| 533 | MOD: cliente.mod | ||
| 471 | }; | 534 | }; |
| 472 | var domicilioStamp = | 535 | var domicilioStamp = |
| 473 | domicilio.Calle + ' ' + domicilio.Numero + ', ' + | 536 | domicilio.Calle + ' ' + domicilio.Numero + ', ' + |
| 474 | domicilio.Localidad + ', ' + domicilio.Provincia; | 537 | domicilio.Localidad + ', ' + domicilio.Provincia; |
| 475 | $scope.notaPedido.domicilioStamp = domicilioStamp; | 538 | $scope.notaPedido.domicilioStamp = domicilioStamp; |
| 476 | 539 | ||
| 477 | $scope.notaPedido.notaPedidoPuntoDescarga = domicilio.puntosDescarga; | 540 | $scope.notaPedido.notaPedidoPuntoDescarga = domicilio.puntosDescarga; |
| 478 | 541 | ||
| 479 | $scope.$broadcast('addCabecera', { | 542 | $scope.$broadcast('addCabecera', { |
| 480 | label: 'Cliente:', | 543 | label: 'Cliente:', |
| 481 | valor: $filter('rellenarDigitos')(cliente.cod, 5) + ' - ' + cliente.nom | 544 | valor: $filter('rellenarDigitos')(cliente.cod, 5) + ' - ' + cliente.nom |
| 482 | }); | 545 | }); |
| 483 | $scope.$broadcast('addCabecera', { | 546 | $scope.$broadcast('addCabecera', { |
| 484 | label: 'Domicilio:', | 547 | label: 'Domicilio:', |
| 485 | valor: domicilioStamp | 548 | valor: domicilioStamp |
| 486 | }); | 549 | }); |
| 487 | if(domicilio.verPuntos) { | 550 | if (domicilio.verPuntos) { |
| 488 | delete $scope.notaPedido.domicilio.verPuntos; | 551 | delete $scope.notaPedido.domicilio.verPuntos; |
| 489 | $scope.seleccionarPuntosDeDescarga(); | 552 | $scope.seleccionarPuntosDeDescarga(); |
| 490 | }else { | 553 | } else { |
| 491 | crearNotaPedidoService | 554 | crearNotaPedidoService |
| 492 | .getPuntosDescargaByClienDom(domicilio.id, cliente.cod) | 555 | .getPuntosDescargaByClienDom(domicilio.id, cliente.cod) |
| 493 | .then(function(res) { | 556 | .then(function(res) { |
| 494 | if(res.data.length) $scope.seleccionarPuntosDeDescarga(); | 557 | if (res.data.length) $scope.seleccionarPuntosDeDescarga(); |
| 495 | }); | 558 | }); |
| 496 | } | 559 | } |
| 497 | }, function() { | 560 | }, function() { |
| 498 | $scope.seleccionarCliente(); | 561 | $scope.seleccionarCliente(true); |
| 499 | return; | 562 | return; |
| 500 | } | 563 | } |
| 501 | ); | 564 | ); |
| 502 | }; | 565 | }; |
| 503 | 566 | ||
| 504 | $scope.getTotal = function() { | 567 | $scope.getTotal = function() { |
| 505 | var total = 0; | 568 | var total = 0; |
| 506 | if ($scope.notaPedido.articulosNotaPedido) { | 569 | if ($scope.notaPedido.articulosNotaPedido) { |
| 507 | var arrayTempArticulos = $scope.notaPedido.articulosNotaPedido; | 570 | var arrayTempArticulos = $scope.notaPedido.articulosNotaPedido; |
| 508 | for (var i = 0; i < arrayTempArticulos.length; i++) { | 571 | for (var i = 0; i < arrayTempArticulos.length; i++) { |
| 509 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; | 572 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; |
| 510 | } | 573 | } |
| 511 | } | 574 | } |
| 512 | 575 | ||
| 513 | return parseFloat(total.toFixed(2)); | 576 | return parseFloat(total.toFixed(2)); |
| 514 | }; | 577 | }; |
| 515 | 578 | ||
| 516 | $scope.getSubTotal = function() { | 579 | $scope.getSubTotal = function() { |
| 517 | if($scope.articuloACargar) { | 580 | if ($scope.articuloACargar) { |
| 518 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; | 581 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; |
| 519 | } | 582 | } |
| 520 | }; | 583 | }; |
| 521 | 584 | ||
| 522 | $scope.seleccionarPreciosYCondiciones = function() { | 585 | $scope.seleccionarPreciosYCondiciones = function() { |
| 586 | if (!$scope.notaPedido.cliente.COD) { | ||
| 587 | focaModalService.alert('Primero seleccione un cliente'); | ||
| 588 | return; | ||
| 589 | } | ||
| 523 | if(validarNotaRemitada()) { | 590 | if(validarNotaRemitada()) { |
| 524 | var modalInstance = $uibModal.open( | 591 | var modalInstance = $uibModal.open( |
| 525 | { | 592 | { |
| 526 | ariaLabelledBy: 'Busqueda de Precio Condición', | 593 | ariaLabelledBy: 'Busqueda de Precio Condición', |
| 527 | templateUrl: 'modal-precio-condicion.html', | 594 | templateUrl: 'modal-precio-condicion.html', |
| 528 | controller: 'focaModalPrecioCondicionController', | 595 | controller: 'focaModalPrecioCondicionController', |
| 529 | size: 'lg' | 596 | size: 'lg', |
| 597 | resolve: { | ||
| 598 | idListaPrecio: function() { | ||
| 599 | return $scope.notaPedido.cliente.MOD || null; | ||
| 600 | } | ||
| 601 | } | ||
| 530 | } | 602 | } |
| 531 | ); | 603 | ); |
| 532 | modalInstance.result.then( | 604 | modalInstance.result.then( |
| 533 | function(precioCondicion) { | 605 | function(precioCondicion) { |
| 534 | var cabecera = ''; | 606 | var cabecera = ''; |
| 535 | var plazosConcat = ''; | 607 | var plazosConcat = ''; |
| 536 | if(!Array.isArray(precioCondicion)) { | 608 | if (!Array.isArray(precioCondicion)) { |
| 537 | $scope.notaPedido.notaPedidoPlazo = precioCondicion.plazoPago; | 609 | $scope.notaPedido.notaPedidoPlazo = precioCondicion.plazoPago; |
| 538 | $scope.notaPedido.precioCondicion = precioCondicion; | 610 | $scope.notaPedido.precioCondicion = precioCondicion; |
| 539 | $scope.notaPedido.idPrecioCondicion = precioCondicion.id; | 611 | $scope.notaPedido.idPrecioCondicion = precioCondicion.id; |
| 540 | $scope.idLista = precioCondicion.idListaPrecio; | 612 | $scope.idLista = precioCondicion.idListaPrecio; |
| 541 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { | 613 | for (var i = 0; i < precioCondicion.plazoPago.length; i++) { |
| 542 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; | 614 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; |
| 543 | } | 615 | } |
| 544 | cabecera = $filter('rellenarDigitos')(precioCondicion.id, 4) + | 616 | cabecera = $filter('rellenarDigitos')(precioCondicion.id, 4) + |
| 545 | ' - ' + precioCondicion.nombre + ' ' + plazosConcat.trim(); | 617 | ' - ' + precioCondicion.nombre + ' ' + plazosConcat.trim(); |
| 546 | } else { //Cuando se ingresan los plazos manualmente | 618 | } else { //Cuando se ingresan los plazos manualmente |
| 547 | $scope.notaPedido.idPrecioCondicion = 0; | 619 | $scope.notaPedido.idPrecioCondicion = 0; |
| 548 | //-1, el modal productos busca todos los productos | 620 | //-1, el modal productos busca todos los productos |
| 549 | $scope.idLista = -1; | 621 | $scope.idLista = -1; |
| 550 | $scope.notaPedido.notaPedidoPlazo = precioCondicion; | 622 | $scope.notaPedido.notaPedidoPlazo = precioCondicion; |
| 551 | for(var j = 0; j < precioCondicion.length; j++) { | 623 | for (var j = 0; j < precioCondicion.length; j++) { |
| 552 | plazosConcat += precioCondicion[j].dias + ' '; | 624 | plazosConcat += precioCondicion[j].dias + ' '; |
| 553 | } | 625 | } |
| 554 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); | 626 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); |
| 555 | } | 627 | } |
| 556 | $scope.notaPedido.articulosNotaPedido = []; | 628 | $scope.notaPedido.articulosNotaPedido = []; |
| 557 | $scope.$broadcast('addCabecera', { | 629 | $scope.$broadcast('addCabecera', { |
| 558 | label: 'Precios y condiciones:', | 630 | label: 'Precios y condiciones:', |
| 559 | valor: cabecera | 631 | valor: cabecera |
| 560 | }); | 632 | }); |
| 561 | }, function() { | 633 | }, function() { |
| 562 | 634 | ||
| 563 | } | 635 | } |
| 564 | ); | 636 | ); |
| 565 | } | 637 | } |
| 566 | }; | 638 | }; |
| 567 | 639 | ||
| 568 | $scope.seleccionarFlete = function() { | ||
| 569 | if(validarNotaRemitada()) { | ||
| 570 | var modalInstance = $uibModal.open( | ||
| 571 | { | ||
| 572 | ariaLabelledBy: 'Busqueda de Flete', | ||
| 573 | templateUrl: 'modal-flete.html', | ||
| 574 | controller: 'focaModalFleteController', | ||
| 575 | size: 'lg', | ||
| 576 | resolve: { | ||
| 577 | parametrosFlete: | ||
| 578 | function() { | ||
| 579 | return { | ||
| 580 | flete: $scope.notaPedido.fob ? 'FOB' : | ||
| 581 | ( $scope.notaPedido.flete ? '1' : | ||
| 582 | ($scope.notaPedido.flete === undefined ? | ||
| 583 | null : '0')), | ||
| 584 | bomba: $scope.notaPedido.bomba ? '1' : | ||
| 585 | ($scope.notaPedido.bomba === undefined ? | ||
| 586 | null : '0'), | ||
| 587 | kilometros: $scope.notaPedido.kilometros | ||
| 588 | }; | ||
| 589 | } | ||
| 590 | } | ||
| 591 | } | ||
| 592 | ); | ||
| 593 | modalInstance.result.then( | ||
| 594 | function(datos) { | ||
| 595 | $scope.notaPedido.flete = datos.flete; | ||
| 596 | $scope.notaPedido.fob = datos.FOB; | ||
| 597 | $scope.notaPedido.bomba = datos.bomba; | ||
| 598 | $scope.notaPedido.kilometros = datos.kilometros; | ||
| 599 | $scope.$broadcast('addCabecera', { | ||
| 600 | label: 'Flete:', | ||
| 601 | valor: datos.FOB ? 'FOB' : (datos.flete ? 'Si' : 'No') | ||
| 602 | }); | ||
| 603 | if(datos.flete) { | ||
| 604 | $scope.$broadcast('addCabecera', { | ||
| 605 | label: 'Bomba:', | ||
| 606 | valor: datos.bomba ? 'Si' : 'No' | ||
| 607 | }); | ||
| 608 | $scope.$broadcast('addCabecera', { | ||
| 609 | label: 'Kilometros:', | ||
| 610 | valor: datos.kilometros | ||
| 611 | }); | ||
| 612 | } else { | ||
| 613 | $scope.$broadcast('removeCabecera', 'Bomba:'); | ||
| 614 | $scope.$broadcast('removeCabecera', 'Kilometros:'); | ||
| 615 | $scope.notaPedido.bomba = false; | ||
| 616 | $scope.notaPedido.kilometros = null; | ||
| 617 | } | ||
| 618 | }, function() { | ||
| 619 | |||
| 620 | } | ||
| 621 | ); | ||
| 622 | } | ||
| 623 | }; | ||
| 624 | |||
| 625 | $scope.seleccionarMoneda = function() { | 640 | $scope.seleccionarMoneda = function() { |
| 626 | if(validarNotaRemitada()) { | 641 | if (validarNotaRemitada()) { |
| 627 | var parametrosModal = { | 642 | var parametrosModal = { |
| 628 | titulo: 'Búsqueda de monedas', | 643 | titulo: 'Búsqueda de monedas', |
| 629 | query: '/moneda', | 644 | query: '/moneda', |
| 630 | columnas: [ | 645 | columnas: [ |
| 631 | { | 646 | { |
| 632 | propiedad: 'DETALLE', | 647 | propiedad: 'DETALLE', |
| 633 | nombre: 'Nombre' | 648 | nombre: 'Nombre' |
| 634 | }, | 649 | }, |
| 635 | { | 650 | { |
| 636 | propiedad: 'SIMBOLO', | 651 | propiedad: 'SIMBOLO', |
| 637 | nombre: 'Símbolo' | 652 | nombre: 'Símbolo' |
| 638 | } | 653 | } |
| 639 | ], | 654 | ], |
| 640 | size: 'md' | 655 | size: 'md' |
| 641 | }; | 656 | }; |
| 642 | focaModalService.modal(parametrosModal).then( | 657 | focaModalService.modal(parametrosModal).then( |
| 643 | function(moneda) { | 658 | function(moneda) { |
| 644 | $scope.abrirModalCotizacion(moneda); | 659 | $scope.abrirModalCotizacion(moneda); |
| 645 | }, function() { | 660 | }, function() { |
| 646 | 661 | ||
| 647 | } | 662 | } |
| 648 | ); | 663 | ); |
| 649 | } | 664 | } |
| 650 | }; | 665 | }; |
| 651 | 666 | ||
| 652 | $scope.seleccionarObservaciones = function() { | 667 | $scope.seleccionarObservaciones = function() { |
| 668 | var observacion = { | ||
| 669 | titulo: 'Ingrese Observaciones', | ||
| 670 | value: $scope.notaPedido.observaciones, | ||
| 671 | maxlength: 155, | ||
| 672 | textarea: true | ||
| 673 | }; | ||
| 674 | |||
| 653 | focaModalService | 675 | focaModalService |
| 654 | .prompt('Ingrese observaciones', $scope.notaPedido.observaciones, true) | 676 | .prompt(observacion) |
| 655 | .then(function(observaciones) { | 677 | .then(function(observaciones) { |
| 678 | $scope.$broadcast('addCabecera', { | ||
| 679 | label: 'Observaciones:', | ||
| 680 | valor: observaciones | ||
| 681 | }); | ||
| 656 | $scope.notaPedido.observaciones = observaciones; | 682 | $scope.notaPedido.observaciones = observaciones; |
| 657 | }); | 683 | }); |
| 658 | }; | 684 | }; |
| 659 | 685 | ||
| 660 | $scope.abrirModalCotizacion = function(moneda) { | 686 | $scope.abrirModalCotizacion = function(moneda) { |
| 661 | var modalInstance = $uibModal.open( | 687 | var modalInstance = $uibModal.open( |
| 662 | { | 688 | { |
| 663 | ariaLabelledBy: 'Busqueda de Cotización', | 689 | ariaLabelledBy: 'Busqueda de Cotización', |
| 664 | templateUrl: 'modal-cotizacion.html', | 690 | templateUrl: 'modal-cotizacion.html', |
| 665 | controller: 'focaModalCotizacionController', | 691 | controller: 'focaModalCotizacionController', |
| 666 | size: 'lg', | 692 | size: 'lg', |
| 667 | resolve: { | 693 | resolve: { |
| 668 | idMoneda: function() { | 694 | idMoneda: function() { |
| 669 | return moneda.ID; | 695 | return moneda.ID; |
| 670 | } | 696 | } |
| 671 | } | 697 | } |
| 672 | } | 698 | } |
| 673 | ); | 699 | ); |
| 674 | modalInstance.result.then( | 700 | modalInstance.result.then( |
| 675 | function(cotizacion) { | 701 | function(cotizacion) { |
| 676 | var articulosTablaTemp = $scope.notaPedido.articulosNotaPedido || []; | 702 | var articulosTablaTemp = $scope.notaPedido.articulosNotaPedido || []; |
| 677 | for(var i = 0; i < articulosTablaTemp.length; i++) { | 703 | for (var i = 0; i < articulosTablaTemp.length; i++) { |
| 678 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * | 704 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * |
| 679 | $scope.notaPedido.cotizacion.VENDEDOR; | 705 | $scope.notaPedido.cotizacion.VENDEDOR; |
| 680 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / | 706 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / |
| 681 | cotizacion.VENDEDOR; | 707 | cotizacion.VENDEDOR; |
| 682 | } | 708 | } |
| 683 | $scope.notaPedido.articulosNotaPedido = articulosTablaTemp; | 709 | $scope.notaPedido.articulosNotaPedido = articulosTablaTemp; |
| 684 | $scope.notaPedido.cotizacion = cotizacion; | 710 | $scope.notaPedido.cotizacion = cotizacion; |
| 685 | $scope.notaPedido.cotizacion.moneda = moneda; | 711 | $scope.notaPedido.cotizacion.moneda = moneda; |
| 686 | if(moneda.DETALLE === 'PESOS ARGENTINOS') { | 712 | if (moneda.DETALLE === 'PESOS ARGENTINOS') { |
| 687 | $scope.$broadcast('removeCabecera', 'Moneda:'); | 713 | $scope.$broadcast('removeCabecera', 'Moneda:'); |
| 688 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); | 714 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); |
| 689 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); | 715 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); |
| 690 | } else { | 716 | } else { |
| 691 | $scope.$broadcast('addCabecera', { | 717 | $scope.$broadcast('addCabecera', { |
| 692 | label: 'Moneda:', | 718 | label: 'Moneda:', |
| 693 | valor: moneda.DETALLE | 719 | valor: moneda.DETALLE |
| 694 | }); | 720 | }); |
| 695 | $scope.$broadcast('addCabecera', { | 721 | $scope.$broadcast('addCabecera', { |
| 696 | label: 'Fecha cotizacion:', | 722 | label: 'Fecha cotizacion:', |
| 697 | valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') | 723 | valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') |
| 698 | }); | 724 | }); |
| 699 | $scope.$broadcast('addCabecera', { | 725 | $scope.$broadcast('addCabecera', { |
| 700 | label: 'Cotizacion:', | 726 | label: 'Cotizacion:', |
| 701 | valor: $filter('number')(cotizacion.VENDEDOR, '2') | 727 | valor: $filter('number')(cotizacion.VENDEDOR, '2') |
| 702 | }); | 728 | }); |
| 703 | } | 729 | } |
| 704 | }, function() { | 730 | }, function() { |
| 705 | 731 | ||
| 706 | } | 732 | } |
| 707 | ); | 733 | ); |
| 708 | }; | 734 | }; |
| 709 | 735 | ||
| 710 | $scope.agregarATabla = function(key) { | 736 | $scope.agregarATabla = function(key) { |
| 711 | if(key === 13) { | 737 | if (key === 13) { |
| 712 | if($scope.articuloACargar.cantidad === undefined || | 738 | if ($scope.articuloACargar.cantidad === undefined || |
| 713 | $scope.articuloACargar.cantidad === 0 || | 739 | $scope.articuloACargar.cantidad === 0 || |
| 714 | $scope.articuloACargar.cantidad === null ) { | 740 | $scope.articuloACargar.cantidad === null ) { |
| 715 | focaModalService.alert('El valor debe ser al menos 1'); | 741 | focaModalService.alert('El valor debe ser al menos 1'); |
| 716 | return; | 742 | return; |
| 717 | } | 743 | } |
| 718 | delete $scope.articuloACargar.sectorCodigo; | 744 | delete $scope.articuloACargar.sectorCodigo; |
| 719 | $scope.notaPedido.articulosNotaPedido.push($scope.articuloACargar); | 745 | $scope.notaPedido.articulosNotaPedido.push($scope.articuloACargar); |
| 720 | $scope.cargando = true; | 746 | $scope.cargando = true; |
| 721 | } | 747 | } |
| 722 | }; | 748 | }; |
| 723 | 749 | ||
| 724 | $scope.quitarArticulo = function(key) { | 750 | $scope.quitarArticulo = function(key) { |
| 725 | $scope.notaPedido.articulosNotaPedido.splice(key, 1); | 751 | $scope.notaPedido.articulosNotaPedido.splice(key, 1); |
| 726 | }; | 752 | }; |
| 727 | 753 | ||
| 728 | $scope.editarArticulo = function(key, articulo) { | 754 | $scope.editarArticulo = function(key, articulo) { |
| 729 | if(key === 13) { | 755 | if (key === 13) { |
| 730 | if(articulo.cantidad === null || articulo.cantidad === 0 || | 756 | if (articulo.cantidad === null || articulo.cantidad === 0 || |
| 731 | articulo.cantidad === undefined) { | 757 | articulo.cantidad === undefined) { |
| 732 | focaModalService.alert('El valor debe ser al menos 1'); | 758 | focaModalService.alert('El valor debe ser al menos 1'); |
| 733 | return; | 759 | return; |
| 734 | } | 760 | } |
| 735 | articulo.editCantidad = false; | 761 | articulo.editCantidad = false; |
| 736 | articulo.editPrecio = false; | 762 | articulo.editPrecio = false; |
| 737 | } | 763 | } |
| 738 | }; | 764 | }; |
| 739 | 765 | ||
| 740 | $scope.cambioEdit = function(articulo, propiedad) { | 766 | $scope.cambioEdit = function(articulo, propiedad) { |
| 741 | if(propiedad === 'cantidad') { | 767 | if (propiedad === 'cantidad') { |
| 742 | articulo.editCantidad = true; | 768 | articulo.editCantidad = true; |
| 743 | } else if(propiedad === 'precio') { | 769 | } else if (propiedad === 'precio') { |
| 744 | articulo.editPrecio = true; | 770 | articulo.editPrecio = true; |
| 745 | } | 771 | } |
| 746 | }; | 772 | }; |
| 747 | 773 | ||
| 748 | $scope.resetFilter = function() { | 774 | $scope.resetFilter = function() { |
| 749 | $scope.articuloACargar = {}; | 775 | $scope.articuloACargar = {}; |
| 750 | $scope.cargando = true; | 776 | $scope.cargando = true; |
| 751 | }; | 777 | }; |
| 752 | //Recibe aviso si el teclado está en uso | 778 | //Recibe aviso si el teclado está en uso |
| 753 | $rootScope.$on('usarTeclado', function(event, data) { | 779 | $rootScope.$on('usarTeclado', function(event, data) { |
| 754 | if(data) { | 780 | if (data) { |
| 755 | $scope.mostrarTeclado = true; | 781 | $scope.mostrarTeclado = true; |
| 756 | return; | 782 | return; |
| 757 | } | 783 | } |
| 758 | $scope.mostrarTeclado = false; | 784 | $scope.mostrarTeclado = false; |
| 759 | }); | 785 | }); |
| 760 | 786 | ||
| 761 | $scope.selectFocus = function($event) { | 787 | $scope.selectFocus = function($event) { |
| 762 | // Si el teclado esta en uso no selecciona el valor | 788 | // Si el teclado esta en uso no selecciona el valor |
| 763 | if($scope.mostrarTeclado) { | 789 | if ($scope.mostrarTeclado) { |
| 764 | return; | 790 | return; |
| 765 | } | 791 | } |
| 766 | $event.target.select(); | 792 | $event.target.select(); |
| 767 | }; | 793 | }; |
| 768 | 794 | ||
| 769 | $scope.salir = function() { | 795 | $scope.salir = function() { |
| 770 | $location.path('/'); | 796 | $location.path('/'); |
| 771 | }; | 797 | }; |
| 772 | 798 | ||
| 773 | $scope.parsearATexto = function(articulo) { | 799 | $scope.parsearATexto = function(articulo) { |
| 774 | articulo.cantidad = parseFloat(articulo.cantidad); | 800 | articulo.cantidad = parseFloat(articulo.cantidad); |
| 775 | articulo.precio = parseFloat(articulo.precio); | 801 | articulo.precio = parseFloat(articulo.precio); |
| 776 | }; | 802 | }; |
| 777 | 803 | ||
| 778 | function setearNotaPedido(notaPedido) { | 804 | function setearNotaPedido(notaPedido) { |
| 779 | //añado cabeceras | 805 | //añado cabeceras |
| 780 | $scope.notaPedido = notaPedido; | 806 | $scope.notaPedido = notaPedido; |
| 781 | $scope.$broadcast('removeCabecera', 'Bomba:'); | 807 | $scope.$broadcast('removeCabecera', 'Bomba:'); |
| 782 | $scope.$broadcast('removeCabecera', 'Kilometros:'); | 808 | $scope.$broadcast('removeCabecera', 'Kilometros:'); |
| 783 | 809 | ||
| 784 | var cabeceras = []; | 810 | var cabeceras = []; |
| 785 | 811 | ||
| 786 | if (notaPedido.cotizacion) { | 812 | if (notaPedido.cotizacion) { |
| 787 | cabeceras.push({ | 813 | cabeceras.push({ |
| 788 | label: 'Moneda:', | 814 | label: 'Moneda:', |
| 789 | valor: notaPedido.cotizacion.moneda.DETALLE | 815 | valor: notaPedido.cotizacion.moneda.DETALLE |
| 790 | }); | 816 | }); |
| 791 | cabeceras.push({ | 817 | cabeceras.push({ |
| 792 | label: 'Fecha cotizacion:', | 818 | label: 'Fecha cotizacion:', |
| 793 | valor: $filter('date')(notaPedido.cotizacion.FECHA, | 819 | valor: $filter('date')(notaPedido.cotizacion.FECHA, |
| 794 | 'dd/MM/yyyy') | 820 | 'dd/MM/yyyy') |
| 795 | }); | 821 | }); |
| 796 | cabeceras.push({ | 822 | cabeceras.push({ |
| 797 | label: 'Cotizacion:', | 823 | label: 'Cotizacion:', |
| 798 | valor: $filter('number')(notaPedido.cotizacion.VENDEDOR, | 824 | valor: $filter('number')(notaPedido.cotizacion.VENDEDOR, |
| 799 | '2') | 825 | '2') |
| 800 | }); | 826 | }); |
| 801 | } | 827 | } |
| 828 | |||
| 802 | if (notaPedido.cliente.COD) { | 829 | if (notaPedido.cliente.COD) { |
| 803 | cabeceras.push({ | 830 | cabeceras.push({ |
| 804 | label: 'Cliente:', | 831 | label: 'Cliente:', |
| 805 | valor: notaPedido.cliente.NOM | 832 | valor: notaPedido.cliente.NOM |
| 806 | }); | 833 | }); |
| 807 | cabeceras.push({ | 834 | cabeceras.push({ |
| 808 | label: 'Domicilio:', | 835 | label: 'Domicilio:', |
| 809 | valor: notaPedido.domicilioStamp | 836 | valor: notaPedido.domicilioStamp |
| 810 | }); | 837 | }); |
| 811 | } | 838 | } |
| 839 | |||
| 812 | if (notaPedido.vendedor.NUM) { | 840 | if (notaPedido.vendedor.NUM) { |
| 813 | cabeceras.push({ | 841 | cabeceras.push({ |
| 814 | label: 'Vendedor:', | 842 | label: 'Vendedor:', |
| 815 | valor: $filter('rellenarDigitos')(notaPedido.vendedor.NUM, 3) + | 843 | valor: $filter('rellenarDigitos')(notaPedido.vendedor.NUM, 3) + |
| 816 | ' - ' + notaPedido.vendedor.NOM | 844 | ' - ' + notaPedido.vendedor.NOM |
| 817 | }); | 845 | }); |
| 818 | } | 846 | } |
| 847 | |||
| 819 | if (notaPedido.proveedor.COD) { | 848 | if (notaPedido.proveedor.COD) { |
| 820 | cabeceras.push({ | 849 | cabeceras.push({ |
| 821 | label: 'Proveedor:', | 850 | label: 'Proveedor:', |
| 822 | valor: $filter('rellenarDigitos')(notaPedido.proveedor.COD, 5) + | 851 | valor: $filter('rellenarDigitos')(notaPedido.proveedor.COD, 5) + |
| 823 | ' - ' + notaPedido.proveedor.NOM | 852 | ' - ' + notaPedido.proveedor.NOM |
| 824 | }); | 853 | }); |
| 825 | } | 854 | } |
| 855 | |||
| 826 | if (notaPedido.notaPedidoPlazo.length) { | 856 | if (notaPedido.notaPedidoPlazo.length) { |
| 827 | cabeceras.push({ | 857 | cabeceras.push({ |
| 828 | label: 'Precios y condiciones:', | 858 | label: 'Precios y condiciones:', |
| 829 | valor: valorPrecioCondicion() + ' ' + | 859 | valor: valorPrecioCondicion() + ' ' + |
| 830 | notaPedidoBusinessService | 860 | notaPedidoBusinessService |
| 831 | .plazoToString(notaPedido.notaPedidoPlazo) | 861 | .plazoToString(notaPedido.notaPedidoPlazo) |
| 832 | }); | 862 | }); |
| 833 | } | 863 | } |
| 864 | |||
| 834 | if (notaPedido.flete !== undefined) { | 865 | if (notaPedido.flete !== undefined) { |
| 835 | cabeceras.push({ | 866 | cabeceras.push({ |
| 836 | label: 'Flete:', | 867 | label: 'Flete:', |
| 837 | valor: notaPedido.fob === 1 ? 'FOB' : ( | 868 | valor: notaPedido.fob === 1 ? 'FOB' : ( |
| 838 | notaPedido.flete === 1 ? 'Si' : 'No') | 869 | notaPedido.flete === 1 ? 'Si' : 'No') |
| 839 | }); | 870 | }); |
| 840 | } | 871 | } |
| 841 | 872 | ||
| 842 | |||
| 843 | function valorPrecioCondicion() { | 873 | function valorPrecioCondicion() { |
| 844 | if (notaPedido.idPrecioCondicion > 0) { | 874 | if (notaPedido.idPrecioCondicion > 0) { |
| 845 | return notaPedido.precioCondicion.nombre; | 875 | return notaPedido.precioCondicion.nombre; |
| 846 | } else { | 876 | } else { |
| 847 | return 'Ingreso Manual'; | 877 | return 'Ingreso Manual'; |
| 848 | } | 878 | } |
| 849 | } | 879 | } |
| 850 | 880 | ||
| 851 | if (notaPedido.flete === 1) { | 881 | if (notaPedido.flete === 1) { |
| 852 | var cabeceraBomba = { | 882 | var cabeceraBomba = { |
| 853 | label: 'Bomba:', | 883 | label: 'Bomba:', |
| 854 | valor: notaPedido.bomba === 1 ? 'Si' : 'No' | 884 | valor: notaPedido.bomba === 1 ? 'Si' : 'No' |
| 855 | }; | 885 | }; |
| 856 | if (notaPedido.kilometros) { | 886 | if (notaPedido.kilometros) { |
| 857 | var cabeceraKilometros = { | 887 | var cabeceraKilometros = { |
| 858 | label: 'Kilometros:', | 888 | label: 'Kilometros:', |
| 859 | valor: notaPedido.kilometros | 889 | valor: notaPedido.kilometros |
| 860 | }; | 890 | }; |
| 861 | cabeceras.push(cabeceraKilometros); | 891 | cabeceras.push(cabeceraKilometros); |
| 862 | } | 892 | } |
| 863 | cabeceras.push(cabeceraBomba); | 893 | cabeceras.push(cabeceraBomba); |
| 864 | } | 894 | } |
| 865 | 895 | ||
| 866 | notaPedidoBusinessService.calcularArticulos($scope.notaPedido.articulosNotaPedido, | 896 | notaPedidoBusinessService.calcularArticulos($scope.notaPedido.articulosNotaPedido, |
| 867 | notaPedido.cotizacion.VENDEDOR); | 897 | notaPedido.cotizacion.VENDEDOR); |
| 868 | 898 | ||
| 869 | if (notaPedido.idPrecioCondicion > 0) { | 899 | if (notaPedido.idPrecioCondicion > 0) { |
| 870 | $scope.idLista = notaPedido.precioCondicion.idListaPrecio; | 900 | $scope.idLista = notaPedido.precioCondicion.idListaPrecio; |
| 871 | } else { | 901 | } else { |
| 872 | $scope.idLista = -1; | 902 | $scope.idLista = -1; |
| 873 | } | 903 | } |
| 874 | 904 | ||
| 875 | $scope.puntoVenta = $filter('rellenarDigitos')( | 905 | $scope.puntoVenta = $filter('rellenarDigitos')( |
| 876 | notaPedido.sucursal, 4 | 906 | notaPedido.sucursal, 4 |
| 877 | ); | 907 | ); |
| 878 | 908 | ||
| 879 | $scope.comprobante = $filter('rellenarDigitos')( | 909 | $scope.comprobante = $filter('rellenarDigitos')( |
| 880 | notaPedido.numeroNotaPedido, 8 | 910 | notaPedido.numeroNotaPedido, 8 |
| 881 | ); | 911 | ); |
| 882 | 912 | ||
| 883 | $scope.notaPedido.notaPedidoPuntoDescarga = | 913 | $scope.notaPedido.notaPedidoPuntoDescarga = |
| 884 | formatearPuntosDescarga(notaPedido.notaPedidoPuntoDescarga || []); | 914 | formatearPuntosDescarga(notaPedido.notaPedidoPuntoDescarga || []); |
| 885 | addArrayCabecera(cabeceras); | 915 | addArrayCabecera(cabeceras); |
| 886 | } | 916 | } |
| 887 | 917 | ||
| 888 | function addArrayCabecera(array) { | 918 | function addArrayCabecera(array) { |
| 889 | for(var i = 0; i < array.length; i++) { | 919 | for (var i = 0; i < array.length; i++) { |
| 890 | $scope.$broadcast('addCabecera', { | 920 | $scope.$broadcast('addCabecera', { |
src/js/service.js
| 1 | angular.module('focaCrearNotaPedido') | 1 | angular.module('focaCrearNotaPedido') |
| 2 | .factory('crearNotaPedidoService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { | 2 | .factory('crearNotaPedidoService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { |
| 3 | var route = API_ENDPOINT.URL; | 3 | var route = API_ENDPOINT.URL; |
| 4 | return { | 4 | return { |
| 5 | crearNotaPedido: function(notaPedido) { | 5 | crearNotaPedido: function(notaPedido) { |
| 6 | return $http.post(route + '/nota-pedido', {notaPedido: notaPedido}); | 6 | return $http.post(route + '/nota-pedido', {notaPedido: notaPedido}); |
| 7 | }, | 7 | }, |
| 8 | obtenerNotaPedido: function() { | 8 | obtenerNotaPedido: function() { |
| 9 | return $http.get(route +'/nota-pedido'); | 9 | return $http.get(route +'/nota-pedido'); |
| 10 | }, | 10 | }, |
| 11 | setNotaPedido: function(notaPedido) { | 11 | setNotaPedido: function(notaPedido) { |
| 12 | this.notaPedido = notaPedido; | 12 | this.notaPedido = notaPedido; |
| 13 | }, | 13 | }, |
| 14 | clearNotaPedido: function() { | 14 | clearNotaPedido: function() { |
| 15 | this.notaPedido = undefined; | 15 | this.notaPedido = undefined; |
| 16 | }, | 16 | }, |
| 17 | getNotaPedido: function() { | 17 | getNotaPedido: function() { |
| 18 | return this.notaPedido; | 18 | return this.notaPedido; |
| 19 | }, | 19 | }, |
| 20 | getArticulosByIdNotaPedido: function(id) { | 20 | getArticulosByIdNotaPedido: function(id) { |
| 21 | return $http.get(route+'/articulos/nota-pedido/'+id); | 21 | return $http.get(route+'/articulos/nota-pedido/'+id); |
| 22 | }, | 22 | }, |
| 23 | crearArticulosParaNotaPedido: function(articuloNotaPedido) { | 23 | crearArticulosParaNotaPedido: function(articuloNotaPedido) { |
| 24 | return $http.post(route + '/articulos/nota-pedido', | 24 | return $http.post(route + '/articulos/nota-pedido', |
| 25 | {articuloNotaPedido: articuloNotaPedido}); | 25 | {articuloNotaPedido: articuloNotaPedido}); |
| 26 | }, | 26 | }, |
| 27 | getDomiciliosByIdNotaPedido: function(id) { | 27 | getDomiciliosByIdNotaPedido: function(id) { |
| 28 | return $http.get(route +'/nota-pedido/'+id+'/domicilios'); | 28 | return $http.get(route +'/nota-pedido/'+id+'/domicilios'); |
| 29 | }, | 29 | }, |
| 30 | getDomiciliosByIdCliente: function(id) { | 30 | getDomiciliosByIdCliente: function(id) { |
| 31 | var idTipoEntrega = 2;//Solo traigo los domicilios que tienen tipo 2 (tipo entrega) | 31 | var idTipoEntrega = 2;//Solo traigo los domicilios que tienen tipo 2 (tipo entrega) |
| 32 | return $http.get(route + '/domicilio/tipo/' + idTipoEntrega + '/cliente/' + id ); | 32 | return $http.get(route + '/domicilio/tipo/' + idTipoEntrega + '/cliente/' + id ); |
| 33 | }, | 33 | }, |
| 34 | getPrecioCondicion: function() { | 34 | getPrecioCondicion: function() { |
| 35 | return $http.get(route + '/precio-condicion'); | 35 | return $http.get(route + '/precio-condicion'); |
| 36 | }, | 36 | }, |
| 37 | getPrecioCondicionById: function(id) { | 37 | getPrecioCondicionById: function(id) { |
| 38 | return $http.get(route + '/precio-condicion/' + id); | 38 | return $http.get(route + '/precio-condicion/' + id); |
| 39 | }, | 39 | }, |
| 40 | getPlazoPagoByPrecioCondicion: function(id) { | 40 | getPlazoPagoByPrecioCondicion: function(id) { |
| 41 | return $http.get(route + '/plazo-pago/precio-condicion/'+ id); | 41 | return $http.get(route + '/plazo-pago/precio-condicion/'+ id); |
| 42 | }, | 42 | }, |
| 43 | crearFlete: function(flete) { | 43 | crearFlete: function(flete) { |
| 44 | return $http.post(route + '/flete', {flete : flete}); | 44 | return $http.post(route + '/flete', {flete : flete}); |
| 45 | }, | 45 | }, |
| 46 | crearPlazosParaNotaPedido: function(plazos) { | 46 | crearPlazosParaNotaPedido: function(plazos) { |
| 47 | return $http.post(route + '/plazo-pago/nota-pedido', {plazos: plazos}); | 47 | return $http.post(route + '/plazo-pago/nota-pedido', {plazos: plazos}); |
| 48 | }, | 48 | }, |
| 49 | getCotizacionByIdMoneda: function(id) { | 49 | getCotizacionByIdMoneda: function(id) { |
| 50 | return $http.get(route + '/moneda/' + id); | 50 | return $http.get(route + '/moneda/' + id); |
| 51 | }, | 51 | }, |
| 52 | crearEstadoParaNotaPedido: function(estado) { | 52 | crearEstadoParaNotaPedido: function(estado) { |
| 53 | return $http.post(route + '/estado', {estado: estado}); | 53 | return $http.post(route + '/estado', {estado: estado}); |
| 54 | }, | 54 | }, |
| 55 | getNumeroNotaPedido: function() { | 55 | getNumeroNotaPedido: function() { |
| 56 | return $http.get(route + '/nota-pedido/numero-siguiente'); | 56 | return $http.get(route + '/nota-pedido/numero-siguiente'); |
| 57 | }, | 57 | }, |
| 58 | getBotonera: function(vendedor) { | 58 | getBotonera: function() { |
| 59 | var result = [ | 59 | var result = [ |
| 60 | { | 60 | { |
| 61 | label: 'Cliente', | 61 | label: 'Cliente', |
| 62 | image: 'cliente.png' | 62 | image: 'cliente.png' |
| 63 | }, | 63 | }, |
| 64 | { | 64 | { |
| 65 | label: 'Proveedor', | 65 | label: 'Transportista', |
| 66 | image: 'proveedor.png' | 66 | image: 'proveedor.png' |
| 67 | }, | 67 | }, |
| 68 | { | 68 | { |
| 69 | label: 'Moneda', | 69 | label: 'Moneda', |
| 70 | image: 'moneda.png' | 70 | image: 'moneda.png' |
| 71 | }, | 71 | }, |
| 72 | { | 72 | { |
| 73 | label: 'Precios y condiciones', | 73 | label: 'Precios y condiciones', |
| 74 | image: 'precios-condiciones.png' | 74 | image: 'precios-condiciones.png' |
| 75 | }, | 75 | }, |
| 76 | { | 76 | { |
| 77 | label: 'Flete', | ||
| 78 | image: 'flete.png' | ||
| 79 | }, | ||
| 80 | { | ||
| 81 | label: 'Productos', | 77 | label: 'Productos', |
| 82 | image: 'productos.png' | 78 | image: 'productos.png' |
| 83 | }, | 79 | }, |
| 84 | { | 80 | { |
| 85 | label: 'Observaciones', | 81 | label: 'Observaciones', |
| 86 | image: 'productos.png' | 82 | image: 'botonObservaciones.png' |
| 87 | } | 83 | } |
| 88 | ]; | 84 | ]; |
| 89 | |||
| 90 | if(!vendedor) { | ||
| 91 | var botonVendedor = { | ||
| 92 | label: 'Vendedor', | ||
| 93 | image: 'vendedor.png' | ||
| 94 | }; | ||
| 95 | |||
| 96 | result.unshift(botonVendedor); | ||
| 97 | } | ||
| 98 | |||
| 99 | return result; | 85 | return result; |
| 100 | }, | 86 | }, |
| 101 | crearPuntosDescarga: function(puntosDescarga) { | 87 | crearPuntosDescarga: function(puntosDescarga) { |
| 102 | return $http.post(route + '/puntos-descarga/nota-pedido', | 88 | return $http.post(route + '/puntos-descarga/nota-pedido', |
| 103 | {puntosDescarga: puntosDescarga}); | 89 | {puntosDescarga: puntosDescarga}); |
| 104 | }, | 90 | }, |
| 105 | getPuntosDescargaByClienDom: function(idDomicilio, idCliente) { | 91 | getPuntosDescargaByClienDom: function(idDomicilio, idCliente) { |
| 106 | return $http.get(API_ENDPOINT.URL + '/punto-descarga/' + | 92 | return $http.get(API_ENDPOINT.URL + '/punto-descarga/' + |
| 107 | idDomicilio + '/' + idCliente); | 93 | idDomicilio + '/' + idCliente); |
| 108 | }, | 94 | }, |
| 109 | getVendedorById: function(id) { | 95 | getVendedorById: function(id) { |
| 110 | return $http.get(API_ENDPOINT.URL + '/vendedor-cobrador/' + id); | 96 | return $http.get(API_ENDPOINT.URL + '/vendedor-cobrador/' + id); |
| 111 | } | 97 | } |
| 112 | }; | 98 | }; |
| 113 | }]); | 99 | }]); |
| 114 | 100 |