Commit a576b0a68d02b5a7f590d2ec107aaaa385417674
Exists in
master
Merge branch 'master' into 'master'
Master(efernandez) See merge request !37
Showing
1 changed file
Show diff stats
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 | function( | 16 | function( |
17 | $scope, $uibModal, $location, $filter, $timeout, crearNotaPedidoService, | 17 | $scope, $uibModal, $location, $filter, $timeout, crearNotaPedidoService, |
18 | focaBotoneraLateralService, focaModalService, notaPedidoBusinessService, | 18 | focaBotoneraLateralService, focaModalService, notaPedidoBusinessService, |
19 | $rootScope, focaSeguimientoService, APP, focaLoginService) | 19 | $rootScope, focaSeguimientoService, APP, focaLoginService) |
20 | { | 20 | { |
21 | if(APP === 'distribuidor') { | 21 | if(APP === 'distribuidor') { |
22 | var idVendedor = focaLoginService.getLoginData().vendedorCobrador; | 22 | var idVendedor = focaLoginService.getLoginData().vendedorCobrador; |
23 | $scope.botonera = crearNotaPedidoService.getBotonera(idVendedor); | 23 | $scope.botonera = crearNotaPedidoService.getBotonera(idVendedor); |
24 | crearNotaPedidoService.getVendedorById(idVendedor).then( | 24 | crearNotaPedidoService.getVendedorById(idVendedor).then( |
25 | function(res) { | 25 | function(res) { |
26 | var vendedor = res.data; | 26 | var vendedor = res.data; |
27 | $scope.$broadcast('addCabecera', { | 27 | $scope.$broadcast('addCabecera', { |
28 | label: 'Vendedor:', | 28 | label: 'Vendedor:', |
29 | valor: $filter('rellenarDigitos')(vendedor.CodVen, 3) + ' - ' + | 29 | valor: $filter('rellenarDigitos')(vendedor.CodVen, 3) + ' - ' + |
30 | vendedor.NomVen | 30 | vendedor.NomVen |
31 | }); | 31 | }); |
32 | $scope.notaPedido.vendedor = vendedor; | 32 | $scope.notaPedido.vendedor = vendedor; |
33 | } | 33 | } |
34 | ); | 34 | ); |
35 | }else { | 35 | }else { |
36 | $scope.botonera = crearNotaPedidoService.getBotonera(); | 36 | $scope.botonera = crearNotaPedidoService.getBotonera(); |
37 | } | 37 | } |
38 | 38 | ||
39 | $scope.isNumber = angular.isNumber; | 39 | $scope.isNumber = angular.isNumber; |
40 | $scope.datepickerAbierto = false; | 40 | $scope.datepickerAbierto = false; |
41 | $scope.show = false; | 41 | $scope.show = false; |
42 | $scope.cargando = true; | 42 | $scope.cargando = true; |
43 | $scope.dateOptions = { | 43 | $scope.dateOptions = { |
44 | maxDate: new Date(), | 44 | maxDate: new Date(), |
45 | minDate: new Date(2010, 0, 1) | 45 | minDate: new Date(2010, 0, 1) |
46 | }; | 46 | }; |
47 | 47 | ||
48 | $scope.notaPedido = { | 48 | $scope.notaPedido = { |
49 | id: 0, | 49 | id: 0, |
50 | vendedor: {}, | 50 | vendedor: {}, |
51 | cliente: {}, | 51 | cliente: {}, |
52 | proveedor: {}, | 52 | proveedor: {}, |
53 | domicilio: {dom: ''}, | 53 | domicilio: {dom: ''}, |
54 | moneda: {}, | 54 | moneda: {}, |
55 | cotizacion: {} | 55 | cotizacion: {} |
56 | }; | 56 | }; |
57 | var monedaPorDefecto; | 57 | var monedaPorDefecto; |
58 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' | 58 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' |
59 | crearNotaPedidoService.getCotizacionByIdMoneda(1).then(function(res) { | 59 | crearNotaPedidoService.getCotizacionByIdMoneda(1).then(function(res) { |
60 | monedaPorDefecto = res.data[0]; | 60 | monedaPorDefecto = res.data[0]; |
61 | $scope.notaPedido.moneda = monedaPorDefecto; | 61 | $scope.notaPedido.moneda = monedaPorDefecto; |
62 | $scope.notaPedido.cotizacion = monedaPorDefecto.cotizaciones[0]; | 62 | $scope.notaPedido.cotizacion = monedaPorDefecto.cotizaciones[0]; |
63 | }); | 63 | }); |
64 | 64 | ||
65 | $scope.cabecera = []; | 65 | $scope.cabecera = []; |
66 | $scope.showCabecera = true; | 66 | $scope.showCabecera = true; |
67 | 67 | ||
68 | $scope.now = new Date(); | 68 | $scope.now = new Date(); |
69 | $scope.puntoVenta = '0000'; | 69 | $scope.puntoVenta = '0000'; |
70 | $scope.comprobante = '00000000'; | 70 | $scope.comprobante = '00000000'; |
71 | $scope.articulosTabla = []; | 71 | $scope.articulosTabla = []; |
72 | $scope.idLista = undefined; | 72 | $scope.idLista = undefined; |
73 | 73 | ||
74 | //SETEO BOTONERA LATERAL | 74 | //SETEO BOTONERA LATERAL |
75 | $timeout(function() { | 75 | $timeout(function() { |
76 | focaBotoneraLateralService.showSalir(false); | 76 | focaBotoneraLateralService.showSalir(false); |
77 | focaBotoneraLateralService.showPausar(true); | 77 | focaBotoneraLateralService.showPausar(true); |
78 | focaBotoneraLateralService.showGuardar(true, $scope.crearNotaPedido); | 78 | focaBotoneraLateralService.showGuardar(true, $scope.crearNotaPedido); |
79 | focaBotoneraLateralService.addCustomButton('Salir', salir); | 79 | focaBotoneraLateralService.addCustomButton('Salir', salir); |
80 | }); | 80 | }); |
81 | 81 | ||
82 | crearNotaPedidoService.getNumeroNotaPedido().then( | 82 | crearNotaPedidoService.getNumeroNotaPedido().then( |
83 | function(res) { | 83 | function(res) { |
84 | $scope.puntoVenta = rellenar(res.data.sucursal, 4); | 84 | $scope.puntoVenta = rellenar(res.data.sucursal, 4); |
85 | $scope.comprobante = rellenar(res.data.numeroNotaPedido, 8); | 85 | $scope.comprobante = rellenar(res.data.numeroNotaPedido, 8); |
86 | }, | 86 | }, |
87 | function(err) { | 87 | function(err) { |
88 | focaModalService.alert('La terminal no esta configurada correctamente'); | 88 | focaModalService.alert('La terminal no esta configurada correctamente'); |
89 | console.info(err); | 89 | console.info(err); |
90 | } | 90 | } |
91 | ); | 91 | ); |
92 | 92 | ||
93 | $scope.crearNotaPedido = function() { | 93 | $scope.crearNotaPedido = function() { |
94 | if(!$scope.notaPedido.vendedor.CodVen) { | 94 | if(!$scope.notaPedido.vendedor.CodVen) { |
95 | focaModalService.alert('Ingrese Vendedor'); | 95 | focaModalService.alert('Ingrese Vendedor'); |
96 | return; | 96 | return; |
97 | } else if(!$scope.notaPedido.cliente.COD) { | 97 | } else if(!$scope.notaPedido.cliente.COD) { |
98 | focaModalService.alert('Ingrese Cliente'); | 98 | focaModalService.alert('Ingrese Cliente'); |
99 | return; | 99 | return; |
100 | } else if(!$scope.notaPedido.proveedor.COD) { | 100 | } else if(!$scope.notaPedido.proveedor.COD) { |
101 | focaModalService.alert('Ingrese Proveedor'); | 101 | focaModalService.alert('Ingrese Proveedor'); |
102 | return; | 102 | return; |
103 | } else if(!$scope.notaPedido.moneda.ID) { | 103 | } else if(!$scope.notaPedido.moneda.ID) { |
104 | focaModalService.alert('Ingrese Moneda'); | 104 | focaModalService.alert('Ingrese Moneda'); |
105 | return; | 105 | return; |
106 | } else if(!$scope.notaPedido.cotizacion.ID) { | 106 | } else if(!$scope.notaPedido.cotizacion.ID) { |
107 | focaModalService.alert('Ingrese Cotización'); | 107 | focaModalService.alert('Ingrese Cotización'); |
108 | return; | 108 | return; |
109 | } else if(!$scope.plazosPagos) { | 109 | } else if(!$scope.plazosPagos) { |
110 | focaModalService.alert('Ingrese Precios y Condiciones'); | 110 | focaModalService.alert('Ingrese Precios y Condiciones'); |
111 | return; | 111 | return; |
112 | } else if( | 112 | } else if( |
113 | $scope.notaPedido.flete === undefined || $scope.notaPedido.flete === null) | 113 | $scope.notaPedido.flete === undefined || $scope.notaPedido.flete === null) |
114 | { | 114 | { |
115 | focaModalService.alert('Ingrese Flete'); | 115 | focaModalService.alert('Ingrese Flete'); |
116 | return; | 116 | return; |
117 | } else if(!$scope.notaPedido.domicilioStamp) {//TODO validar domicilio correcto | 117 | } else if(!$scope.notaPedido.domicilioStamp) {//TODO validar domicilio correcto |
118 | focaModalService.alert('Ingrese Domicilio'); | 118 | focaModalService.alert('Ingrese Domicilio'); |
119 | return; | 119 | return; |
120 | } else if($scope.articulosTabla.length === 0) { | 120 | } else if($scope.articulosTabla.length === 0) { |
121 | focaModalService.alert('Debe cargar al menos un articulo'); | 121 | focaModalService.alert('Debe cargar al menos un articulo'); |
122 | return; | 122 | return; |
123 | } | 123 | } |
124 | focaBotoneraLateralService.startGuardar(); | 124 | focaBotoneraLateralService.startGuardar(); |
125 | $scope.saveLoading = true; | 125 | $scope.saveLoading = true; |
126 | var notaPedido = { | 126 | var notaPedido = { |
127 | id: $scope.notaPedido.id, | 127 | id: $scope.notaPedido.id, |
128 | fechaCarga: $scope.now.toISOString().slice(0, 19).replace('T', ' '), | 128 | fechaCarga: $scope.now.toISOString().slice(0, 19).replace('T', ' '), |
129 | idVendedor: $scope.notaPedido.vendedor.CodVen, | 129 | idVendedor: $scope.notaPedido.vendedor.CodVen, |
130 | idCliente: $scope.notaPedido.cliente.COD, | 130 | idCliente: $scope.notaPedido.cliente.COD, |
131 | nombreCliente: $scope.notaPedido.cliente.NOM, | 131 | nombreCliente: $scope.notaPedido.cliente.NOM, |
132 | cuitCliente: $scope.notaPedido.cliente.CUIT, | 132 | cuitCliente: $scope.notaPedido.cliente.CUIT, |
133 | idProveedor: $scope.notaPedido.proveedor.COD, | 133 | idProveedor: $scope.notaPedido.proveedor.COD, |
134 | //idDomicilio: $scope.notaPedido.domicilio.id,TODO GUARDAR DOMICILIO ID | 134 | //idDomicilio: $scope.notaPedido.domicilio.id,TODO GUARDAR DOMICILIO ID |
135 | idCotizacion: $scope.notaPedido.cotizacion.ID, | 135 | idCotizacion: $scope.notaPedido.cotizacion.ID, |
136 | idPrecioCondicion: $scope.notaPedido.idPrecioCondicion, | 136 | idPrecioCondicion: $scope.notaPedido.idPrecioCondicion, |
137 | cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, | 137 | cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, |
138 | flete: $scope.notaPedido.flete, | 138 | flete: $scope.notaPedido.flete, |
139 | fob: $scope.notaPedido.fob, | 139 | fob: $scope.notaPedido.fob, |
140 | bomba: $scope.notaPedido.bomba, | 140 | bomba: $scope.notaPedido.bomba, |
141 | kilometros: $scope.notaPedido.kilometros, | 141 | kilometros: $scope.notaPedido.kilometros, |
142 | domicilioStamp: $scope.notaPedido.domicilioStamp, | 142 | domicilioStamp: $scope.notaPedido.domicilioStamp, |
143 | estado: 0, | 143 | estado: 0, |
144 | total: $scope.getTotal() | 144 | total: $scope.getTotal() |
145 | }; | 145 | }; |
146 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( | 146 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( |
147 | function(data) { | 147 | function(data) { |
148 | // Al guardar los datos de la nota de pedido logueamos la | 148 | // Al guardar los datos de la nota de pedido logueamos la |
149 | // actividad para su seguimiento. | 149 | // actividad para su seguimiento. |
150 | //TODO: GUARDAR POSISIONAMIENTO AL EDITAR? | 150 | //TODO: GUARDAR POSISIONAMIENTO AL EDITAR? |
151 | focaSeguimientoService.guardarPosicion( | 151 | focaSeguimientoService.guardarPosicion( |
152 | 'Nota de pedido', | 152 | 'Nota de pedido', |
153 | data.data.id, | 153 | data.data.id, |
154 | '' | 154 | '' |
155 | ); | 155 | ); |
156 | notaPedidoBusinessService.addArticulos($scope.articulosTabla, | 156 | notaPedidoBusinessService.addArticulos($scope.articulosTabla, |
157 | data.data.id, $scope.notaPedido.cotizacion.VENDEDOR); | 157 | data.data.id, $scope.notaPedido.cotizacion.VENDEDOR); |
158 | 158 | ||
159 | if($scope.notaPedido.puntosDescarga) { | 159 | if($scope.notaPedido.puntosDescarga) { |
160 | notaPedidoBusinessService.addPuntosDescarga(data.data.id, | 160 | notaPedidoBusinessService.addPuntosDescarga(data.data.id, |
161 | $scope.notaPedido.puntosDescarga); | 161 | $scope.notaPedido.puntosDescarga); |
162 | } | 162 | } |
163 | 163 | ||
164 | var plazos = $scope.plazosPagos; | 164 | var plazos = $scope.plazosPagos; |
165 | var plazosACrear = []; | 165 | var plazosACrear = []; |
166 | plazos.forEach(function(plazo) { | 166 | plazos.forEach(function(plazo) { |
167 | plazosACrear.push({ | 167 | plazosACrear.push({ |
168 | idNotaPedido: data.data.id, | 168 | idNotaPedido: data.data.id, |
169 | dias: plazo.dias | 169 | dias: plazo.dias |
170 | }); | 170 | }); |
171 | }); | 171 | }); |
172 | if(plazosACrear.length){ | 172 | if(plazosACrear.length){ |
173 | crearNotaPedidoService.crearPlazosParaNotaPedido(plazosACrear); | 173 | crearNotaPedidoService.crearPlazosParaNotaPedido(plazosACrear); |
174 | } | 174 | } |
175 | 175 | ||
176 | notaPedidoBusinessService.addEstado(data.data.id, | 176 | notaPedidoBusinessService.addEstado(data.data.id, |
177 | $scope.notaPedido.vendedor.CodVen); | 177 | $scope.notaPedido.vendedor.CodVen); |
178 | 178 | ||
179 | focaBotoneraLateralService.endGuardar(true); | 179 | focaBotoneraLateralService.endGuardar(true); |
180 | $scope.saveLoading = false; | 180 | $scope.saveLoading = false; |
181 | $scope.$broadcast('cleanCabecera'); | 181 | $scope.$broadcast('cleanCabecera'); |
182 | $scope.$broadcast('addCabecera', { | 182 | $scope.$broadcast('addCabecera', { |
183 | label: 'Moneda:', | 183 | label: 'Moneda:', |
184 | valor: $scope.notaPedido.moneda.DETALLE | 184 | valor: $scope.notaPedido.moneda.DETALLE |
185 | }); | 185 | }); |
186 | $scope.$broadcast('addCabecera', { | 186 | $scope.$broadcast('addCabecera', { |
187 | label: 'Fecha cotizacion:', | 187 | label: 'Fecha cotizacion:', |
188 | valor: $filter('date')($scope.notaPedido.cotizacion.FECHA, 'dd/MM/yyyy') | 188 | valor: $filter('date')($scope.notaPedido.cotizacion.FECHA, 'dd/MM/yyyy') |
189 | }); | 189 | }); |
190 | $scope.$broadcast('addCabecera', { | 190 | $scope.$broadcast('addCabecera', { |
191 | label: 'Moneda:', | 191 | label: 'Moneda:', |
192 | valor: $scope.notaPedido.moneda.DETALLE | 192 | valor: $scope.notaPedido.moneda.DETALLE |
193 | }); | 193 | }); |
194 | $scope.$broadcast('addCabecera', { | 194 | $scope.$broadcast('addCabecera', { |
195 | label: 'Cotizacion:', | 195 | label: 'Cotizacion:', |
196 | valor: $filter('number')($scope.notaPedido.cotizacion.VENDEDOR, '2') | 196 | valor: $filter('number')($scope.notaPedido.cotizacion.VENDEDOR, '2') |
197 | }); | 197 | }); |
198 | crearNotaPedidoService.getNumeroNotaPedido().then( | 198 | crearNotaPedidoService.getNumeroNotaPedido().then( |
199 | function(res) { | 199 | function(res) { |
200 | $scope.puntoVenta = rellenar(res.data.sucursal, 4); | 200 | $scope.puntoVenta = rellenar(res.data.sucursal, 4); |
201 | $scope.comprobante = rellenar(res.data.numeroNotaPedido, 8); | 201 | $scope.comprobante = rellenar(res.data.numeroNotaPedido, 8); |
202 | }, | 202 | }, |
203 | function(err) { | 203 | function(err) { |
204 | focaModalService.alert( | 204 | focaModalService.alert( |
205 | 'La terminal no esta configurada correctamente'); | 205 | 'La terminal no esta configurada correctamente'); |
206 | console.info(err); | 206 | console.info(err); |
207 | } | 207 | } |
208 | ); | 208 | ); |
209 | $scope.notaPedido.vendedor = {}; | 209 | $scope.notaPedido.vendedor = {}; |
210 | $scope.notaPedido.cliente = {}; | 210 | $scope.notaPedido.cliente = {}; |
211 | $scope.notaPedido.proveedor = {}; | 211 | $scope.notaPedido.proveedor = {}; |
212 | $scope.notaPedido.domicilio = {}; | 212 | $scope.notaPedido.domicilio = {}; |
213 | $scope.notaPedido.flete = undefined; | 213 | $scope.notaPedido.flete = undefined; |
214 | $scope.notaPedido.fob = undefined; | 214 | $scope.notaPedido.fob = undefined; |
215 | $scope.notaPedido.bomba = undefined; | 215 | $scope.notaPedido.bomba = undefined; |
216 | $scope.notaPedido.kilometros = undefined; | 216 | $scope.notaPedido.kilometros = undefined; |
217 | $scope.articulosTabla = []; | 217 | $scope.articulosTabla = []; |
218 | }, | 218 | }, |
219 | function(error) { | 219 | function(error) { |
220 | focaModalService.alert('Hubo un error al crear la nota de pedido'); | 220 | focaModalService.alert('Hubo un error al crear la nota de pedido'); |
221 | focaBotoneraLateralService.endGuardar(); | 221 | focaBotoneraLateralService.endGuardar(); |
222 | $scope.saveLoading = false; | 222 | $scope.saveLoading = false; |
223 | console.info(error); | 223 | console.info(error); |
224 | } | 224 | } |
225 | ); | 225 | ); |
226 | }; | 226 | }; |
227 | 227 | ||
228 | $scope.seleccionarNotaPedido = function() { | 228 | $scope.seleccionarNotaPedido = function() { |
229 | var modalInstance = $uibModal.open( | 229 | var modalInstance = $uibModal.open( |
230 | { | 230 | { |
231 | ariaLabelledBy: 'Busqueda de Nota de Pedido', | 231 | ariaLabelledBy: 'Busqueda de Nota de Pedido', |
232 | templateUrl: 'foca-modal-nota-pedido.html', | 232 | templateUrl: 'foca-modal-nota-pedido.html', |
233 | controller: 'focaModalNotaPedidoController', | 233 | controller: 'focaModalNotaPedidoController', |
234 | size: 'lg', | 234 | size: 'lg', |
235 | resolve: { | 235 | resolve: { |
236 | usadoPor: function() {return 'notaPedido';}, | 236 | usadoPor: function() {return 'notaPedido';}, |
237 | idVendedor: function() { | 237 | idVendedor: function() { |
238 | if(APP === 'distribuidor') | 238 | if(APP === 'distribuidor') |
239 | return $scope.notaPedido.vendedor.CodVen; | 239 | return $scope.notaPedido.vendedor.CodVen; |
240 | else | 240 | else |
241 | return null; | 241 | return null; |
242 | } | 242 | } |
243 | } | 243 | } |
244 | } | 244 | } |
245 | ); | 245 | ); |
246 | modalInstance.result.then( | 246 | modalInstance.result.then( |
247 | function(notaPedido) { | 247 | function(notaPedido) { |
248 | $scope.now = new Date(notaPedido.fechaCarga); | 248 | $scope.now = new Date(notaPedido.fechaCarga); |
249 | //añado cabeceras | 249 | //añado cabeceras |
250 | $scope.notaPedido.id = notaPedido.id; | 250 | $scope.notaPedido.id = notaPedido.id; |
251 | $scope.$broadcast('removeCabecera', 'Bomba:'); | 251 | $scope.$broadcast('removeCabecera', 'Bomba:'); |
252 | $scope.$broadcast('removeCabecera', 'Kilometros:'); | 252 | $scope.$broadcast('removeCabecera', 'Kilometros:'); |
253 | var cabeceras = [ | 253 | var cabeceras = [ |
254 | { | 254 | { |
255 | label: 'Moneda:', | 255 | label: 'Moneda:', |
256 | valor: notaPedido.cotizacion.moneda.DETALLE | 256 | valor: notaPedido.cotizacion.moneda.DETALLE |
257 | }, | 257 | }, |
258 | { | 258 | { |
259 | label: 'Fecha cotizacion:', | 259 | label: 'Fecha cotizacion:', |
260 | valor: $filter('date')(notaPedido.cotizacion.FECHA, | 260 | valor: $filter('date')(notaPedido.cotizacion.FECHA, |
261 | 'dd/MM/yyyy') | 261 | 'dd/MM/yyyy') |
262 | }, | 262 | }, |
263 | { | 263 | { |
264 | label: 'Cotizacion:', | 264 | label: 'Cotizacion:', |
265 | valor: $filter('number')(notaPedido.cotizacion.VENDEDOR, | 265 | valor: $filter('number')(notaPedido.cotizacion.VENDEDOR, |
266 | '2') | 266 | '2') |
267 | }, | 267 | }, |
268 | { | 268 | { |
269 | label: 'Cliente:', | 269 | label: 'Cliente:', |
270 | valor: notaPedido.cliente.NOM | 270 | valor: notaPedido.cliente.NOM |
271 | }, | 271 | }, |
272 | { | 272 | { |
273 | label: 'Domicilio:', | 273 | label: 'Domicilio:', |
274 | valor: notaPedido.domicilioStamp | 274 | valor: notaPedido.domicilioStamp |
275 | }, | 275 | }, |
276 | { | 276 | { |
277 | label: 'Vendedor:', | 277 | label: 'Vendedor:', |
278 | valor: notaPedido.vendedor.CodVen + ' - ' + | 278 | valor: notaPedido.vendedor.CodVen + ' - ' + |
279 | notaPedido.vendedor.NomVen | 279 | notaPedido.vendedor.NomVen |
280 | }, | 280 | }, |
281 | { | 281 | { |
282 | label: 'Proveedor:', | 282 | label: 'Proveedor:', |
283 | valor: notaPedido.proveedor.NOM | 283 | valor: notaPedido.proveedor.NOM |
284 | }, | 284 | }, |
285 | { | 285 | { |
286 | label: 'Precios y condiciones:', | 286 | label: 'Precios y condiciones:', |
287 | valor: valorPrecioCondicion() + ' ' + | 287 | valor: valorPrecioCondicion() + ' ' + |
288 | notaPedidoBusinessService | 288 | notaPedidoBusinessService |
289 | .plazoToString(notaPedido.notaPedidoPlazo) | 289 | .plazoToString(notaPedido.notaPedidoPlazo) |
290 | }, | 290 | }, |
291 | { | 291 | { |
292 | label: 'Flete:', | 292 | label: 'Flete:', |
293 | valor: notaPedido.fob === 1 ? 'FOB' : ( | 293 | valor: notaPedido.fob === 1 ? 'FOB' : ( |
294 | notaPedido.flete === 1 ? 'Si' : 'No') | 294 | notaPedido.flete === 1 ? 'Si' : 'No') |
295 | } | 295 | } |
296 | ]; | 296 | ]; |
297 | 297 | ||
298 | function valorPrecioCondicion() { | 298 | function valorPrecioCondicion() { |
299 | if(notaPedido.idPrecioCondicion > 0) { | 299 | if(notaPedido.idPrecioCondicion > 0) { |
300 | return notaPedido.precioCondicion.nombre; | 300 | return notaPedido.precioCondicion.nombre; |
301 | } else { | 301 | } else { |
302 | return 'Ingreso Manual'; | 302 | return 'Ingreso Manual'; |
303 | } | 303 | } |
304 | } | 304 | } |
305 | 305 | ||
306 | if(notaPedido.flete === 1) { | 306 | if(notaPedido.flete === 1) { |
307 | var cabeceraBomba = { | 307 | var cabeceraBomba = { |
308 | label: 'Bomba:', | 308 | label: 'Bomba:', |
309 | valor: notaPedido.bomba === 1 ? 'Si' : 'No' | 309 | valor: notaPedido.bomba === 1 ? 'Si' : 'No' |
310 | }; | 310 | }; |
311 | if(notaPedido.kilometros) { | 311 | if(notaPedido.kilometros) { |
312 | var cabeceraKilometros = { | 312 | var cabeceraKilometros = { |
313 | label: 'Kilometros:', | 313 | label: 'Kilometros:', |
314 | valor: notaPedido.kilometros | 314 | valor: notaPedido.kilometros |
315 | }; | 315 | }; |
316 | cabeceras.push(cabeceraKilometros); | 316 | cabeceras.push(cabeceraKilometros); |
317 | } | 317 | } |
318 | cabeceras.push(cabeceraBomba); | 318 | cabeceras.push(cabeceraBomba); |
319 | } | 319 | } |
320 | $scope.articulosTabla = notaPedido.articulosNotaPedido; | 320 | $scope.articulosTabla = notaPedido.articulosNotaPedido; |
321 | notaPedidoBusinessService.calcularArticulos($scope.articulosTabla, | 321 | notaPedidoBusinessService.calcularArticulos($scope.articulosTabla, |
322 | notaPedido.cotizacion.VENDEDOR); | 322 | notaPedido.cotizacion.VENDEDOR); |
323 | if(notaPedido.idPrecioCondicion > 0) { | 323 | if(notaPedido.idPrecioCondicion > 0) { |
324 | $scope.idLista = notaPedido.precioCondicion.idListaPrecio; | 324 | $scope.idLista = notaPedido.precioCondicion.idListaPrecio; |
325 | } else { | 325 | } else { |
326 | $scope.idLista = -1; | 326 | $scope.idLista = -1; |
327 | } | 327 | } |
328 | $scope.puntoVenta = rellenar(notaPedido.sucursal, 4); | 328 | $scope.puntoVenta = rellenar(notaPedido.sucursal, 4); |
329 | $scope.comprobante = rellenar(notaPedido.numeroNotaPedido, 8); | 329 | $scope.comprobante = rellenar(notaPedido.numeroNotaPedido, 8); |
330 | $scope.notaPedido = notaPedido; | 330 | $scope.notaPedido = notaPedido; |
331 | $scope.notaPedido.moneda = notaPedido.cotizacion.moneda; | 331 | $scope.notaPedido.moneda = notaPedido.cotizacion.moneda; |
332 | $scope.plazosPagos = notaPedido.notaPedidoPlazo; | 332 | $scope.plazosPagos = notaPedido.notaPedidoPlazo; |
333 | $scope.notaPedido.puntosDescarga = | 333 | $scope.notaPedido.puntosDescarga = |
334 | formatearPuntosDescarga(notaPedido.notaPedidoPuntoDescarga); | 334 | formatearPuntosDescarga(notaPedido.notaPedidoPuntoDescarga); |
335 | addArrayCabecera(cabeceras); | 335 | addArrayCabecera(cabeceras); |
336 | 336 | ||
337 | }, function() { | 337 | }, function() { |
338 | // funcion ejecutada cuando se cancela el modal | 338 | // funcion ejecutada cuando se cancela el modal |
339 | } | 339 | } |
340 | ); | 340 | ); |
341 | }; | 341 | }; |
342 | 342 | ||
343 | $scope.seleccionarProductos = function() { | 343 | $scope.seleccionarProductos = function() { |
344 | if ($scope.idLista === undefined) { | 344 | if ($scope.idLista === undefined) { |
345 | focaModalService.alert( | 345 | focaModalService.alert( |
346 | 'Primero seleccione una lista de precio y condicion'); | 346 | 'Primero seleccione una lista de precio y condicion'); |
347 | return; | 347 | return; |
348 | } | 348 | } |
349 | var modalInstance = $uibModal.open( | 349 | var modalInstance = $uibModal.open( |
350 | { | 350 | { |
351 | ariaLabelledBy: 'Busqueda de Productos', | 351 | ariaLabelledBy: 'Busqueda de Productos', |
352 | templateUrl: 'modal-busqueda-productos.html', | 352 | templateUrl: 'modal-busqueda-productos.html', |
353 | controller: 'modalBusquedaProductosCtrl', | 353 | controller: 'modalBusquedaProductosCtrl', |
354 | resolve: { | 354 | resolve: { |
355 | parametroProducto: { | 355 | parametroProducto: { |
356 | idLista: $scope.idLista, | 356 | idLista: $scope.idLista, |
357 | cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, | 357 | cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, |
358 | simbolo: $scope.notaPedido.moneda.SIMBOLO | 358 | simbolo: $scope.notaPedido.moneda.SIMBOLO |
359 | } | 359 | } |
360 | }, | 360 | }, |
361 | size: 'lg' | 361 | size: 'lg' |
362 | } | 362 | } |
363 | ); | 363 | ); |
364 | modalInstance.result.then( | 364 | modalInstance.result.then( |
365 | function(producto) { | 365 | function(producto) { |
366 | var newArt = | 366 | var newArt = |
367 | { | 367 | { |
368 | id: 0, | 368 | id: 0, |
369 | codigo: producto.codigo, | 369 | codigo: producto.codigo, |
370 | sector: producto.sector, | 370 | sector: producto.sector, |
371 | sectorCodigo: producto.sector + '-' + producto.codigo, | 371 | sectorCodigo: producto.sector + '-' + producto.codigo, |
372 | descripcion: producto.descripcion, | 372 | descripcion: producto.descripcion, |
373 | item: $scope.articulosTabla.length + 1, | 373 | item: $scope.articulosTabla.length + 1, |
374 | nombre: producto.descripcion, | 374 | nombre: producto.descripcion, |
375 | precio: parseFloat(producto.precio.toFixed(4)), | 375 | precio: parseFloat(producto.precio.toFixed(4)), |
376 | costoUnitario: producto.costo, | 376 | costoUnitario: producto.costo, |
377 | editCantidad: false, | 377 | editCantidad: false, |
378 | editPrecio: false, | 378 | editPrecio: false, |
379 | rubro: producto.CodRub, | 379 | rubro: producto.CodRub, |
380 | exentoUnitario: producto.precio, | 380 | exentoUnitario: producto.precio, |
381 | ivaUnitario: producto.IMPIVA, | 381 | ivaUnitario: producto.IMPIVA, |
382 | impuestoInternoUnitario: producto.ImpInt, | 382 | impuestoInternoUnitario: producto.ImpInt, |
383 | impuestoInterno1Unitario: producto.ImpInt2, | 383 | impuestoInterno1Unitario: producto.ImpInt2, |
384 | impuestoInterno2Unitario: producto.ImpInt3, | 384 | impuestoInterno2Unitario: producto.ImpInt3, |
385 | precioLista: producto.precio, | 385 | precioLista: producto.precio, |
386 | combustible: 1, | 386 | combustible: 1, |
387 | facturado: 0, | 387 | facturado: 0, |
388 | idArticulo: producto.id | 388 | idArticulo: producto.id |
389 | }; | 389 | }; |
390 | $scope.articuloACargar = newArt; | 390 | $scope.articuloACargar = newArt; |
391 | $scope.cargando = false; | 391 | $scope.cargando = false; |
392 | }, function() { | 392 | }, function() { |
393 | // funcion ejecutada cuando se cancela el modal | 393 | // funcion ejecutada cuando se cancela el modal |
394 | } | 394 | } |
395 | ); | 395 | ); |
396 | }; | 396 | }; |
397 | 397 | ||
398 | $scope.seleccionarPuntosDeDescarga = function() { | 398 | $scope.seleccionarPuntosDeDescarga = function() { |
399 | if(!$scope.notaPedido.cliente.COD || !$scope.notaPedido.domicilio.id) { | 399 | if(!$scope.notaPedido.cliente.COD || !$scope.notaPedido.domicilio.id) { |
400 | focaModalService.alert('Primero seleccione un cliente y un domicilio'); | 400 | focaModalService.alert('Primero seleccione un cliente y un domicilio'); |
401 | return; | 401 | return; |
402 | }else { | 402 | }else { |
403 | var modalInstance = $uibModal.open( | 403 | var modalInstance = $uibModal.open( |
404 | { | 404 | { |
405 | ariaLabelledBy: 'Búsqueda de Puntos de descarga', | 405 | ariaLabelledBy: 'Búsqueda de Puntos de descarga', |
406 | templateUrl: 'modal-punto-descarga.html', | 406 | templateUrl: 'modal-punto-descarga.html', |
407 | controller: 'focaModalPuntoDescargaController', | 407 | controller: 'focaModalPuntoDescargaController', |
408 | size: 'lg', | 408 | size: 'lg', |
409 | resolve: { | 409 | resolve: { |
410 | filters: { | 410 | filters: { |
411 | /*TODO: al traer nota de pedido ya creada | 411 | /*TODO: al traer nota de pedido ya creada |
412 | obtener idDomicilio correctamente*/ | 412 | obtener idDomicilio correctamente*/ |
413 | idDomicilio: $scope.notaPedido.domicilio.id, | 413 | idDomicilio: $scope.notaPedido.domicilio.id, |
414 | idCliente: $scope.notaPedido.cliente.COD, | 414 | idCliente: $scope.notaPedido.cliente.COD, |
415 | articulos: $scope.articulosTabla, | 415 | articulos: $scope.articulosTabla, |
416 | puntosDescarga: $scope.notaPedido.puntosDescarga | 416 | puntosDescarga: $scope.notaPedido.puntosDescarga |
417 | } | 417 | } |
418 | } | 418 | } |
419 | } | 419 | } |
420 | ); | 420 | ); |
421 | modalInstance.result.then( | 421 | modalInstance.result.then( |
422 | function(puntosDescarga) { | 422 | function(puntosDescarga) { |
423 | $scope.notaPedido.puntosDescarga = puntosDescarga; | 423 | $scope.notaPedido.puntosDescarga = puntosDescarga; |
424 | 424 | ||
425 | //AGREGO PUNTOS DE DESCARGA A CABECERA | 425 | //AGREGO PUNTOS DE DESCARGA A CABECERA |
426 | var puntosStamp = ''; | 426 | var puntosStamp = ''; |
427 | puntosDescarga.forEach(function(punto, idx, arr) { | 427 | puntosDescarga.forEach(function(punto, idx, arr) { |
428 | puntosStamp += punto.descripcion; | 428 | puntosStamp += punto.descripcion; |
429 | if((idx + 1) !== arr.length) puntosStamp += ', '; | 429 | if((idx + 1) !== arr.length) puntosStamp += ', '; |
430 | }); | 430 | }); |
431 | 431 | ||
432 | $scope.$broadcast('addCabecera', { | 432 | $scope.$broadcast('addCabecera', { |
433 | label: 'Puntos de descarga:', | 433 | label: 'Puntos de descarga:', |
434 | valor: puntosStamp | 434 | valor: puntosStamp |
435 | }); | 435 | }); |
436 | }, function() { | 436 | }, function() { |
437 | $scope.abrirModalDomicilios($scope.cliente); | 437 | $scope.abrirModalDomicilios($scope.cliente); |
438 | } | 438 | } |
439 | ); | 439 | ); |
440 | } | 440 | } |
441 | }; | 441 | }; |
442 | 442 | ||
443 | $scope.seleccionarVendedor = function() { | 443 | $scope.seleccionarVendedor = function() { |
444 | if(validarNotaRemitada()) { | 444 | if(validarNotaRemitada()) { |
445 | var modalInstance = $uibModal.open( | 445 | var parametrosModal = { |
446 | { | 446 | titulo: 'Búsqueda vendedores', |
447 | ariaLabelledBy: 'Busqueda de Vendedores', | 447 | query: '/vendedor', |
448 | templateUrl: 'modal-vendedores.html', | 448 | columnas: [ |
449 | controller: 'modalVendedoresCtrl', | 449 | { |
450 | size: 'lg' | 450 | propiedad: 'CodVen', |
451 | } | 451 | nombre: 'Código', |
452 | ); | 452 | filtro: { |
453 | modalInstance.result.then( | 453 | nombre: 'rellenarDigitos', |
454 | parametro: 3 | ||
455 | } | ||
456 | }, | ||
457 | { | ||
458 | propiedad: 'NomVen', | ||
459 | nombre: 'Nombre' | ||
460 | } | ||
461 | ], | ||
462 | size: 'md' | ||
463 | }; | ||
464 | focaModalService.modal(parametrosModal).then( | ||
454 | function(vendedor) { | 465 | function(vendedor) { |
455 | $scope.$broadcast('addCabecera', { | 466 | $scope.$broadcast('addCabecera', { |
456 | label: 'Vendedor:', | 467 | label: 'Vendedor:', |
457 | valor: $filter('rellenarDigitos')(vendedor.CodVen, 3) + ' - ' + | 468 | valor: $filter('rellenarDigitos')(vendedor.CodVen, 3) + ' - ' + |
458 | vendedor.NomVen | 469 | vendedor.NomVen |
459 | }); | 470 | }); |
460 | $scope.notaPedido.vendedor = vendedor; | 471 | $scope.notaPedido.vendedor = vendedor; |
461 | }, function() { | 472 | }, function() { |
462 | 473 | ||
463 | } | 474 | } |
464 | ); | 475 | ); |
465 | } | 476 | } |
466 | }; | 477 | }; |
467 | 478 | ||
468 | $scope.seleccionarProveedor = function() { | 479 | $scope.seleccionarProveedor = function() { |
469 | if(validarNotaRemitada()) { | 480 | if(validarNotaRemitada()) { |
470 | var modalInstance = $uibModal.open( | 481 | var modalInstance = $uibModal.open( |
471 | { | 482 | { |
472 | ariaLabelledBy: 'Busqueda de Proveedor', | 483 | ariaLabelledBy: 'Busqueda de Proveedor', |
473 | templateUrl: 'modal-proveedor.html', | 484 | templateUrl: 'modal-proveedor.html', |
474 | controller: 'focaModalProveedorCtrl', | 485 | controller: 'focaModalProveedorCtrl', |
475 | size: 'lg', | 486 | size: 'lg', |
476 | resolve: { | 487 | resolve: { |
477 | transportista: function() { | 488 | transportista: function() { |
478 | return false; | 489 | return false; |
479 | } | 490 | } |
480 | } | 491 | } |
481 | } | 492 | } |
482 | ); | 493 | ); |
483 | modalInstance.result.then( | 494 | modalInstance.result.then( |
484 | function(proveedor) { | 495 | function(proveedor) { |
485 | $scope.notaPedido.proveedor = proveedor; | 496 | $scope.notaPedido.proveedor = proveedor; |
486 | $scope.$broadcast('addCabecera', { | 497 | $scope.$broadcast('addCabecera', { |
487 | label: 'Proveedor:', | 498 | label: 'Proveedor:', |
488 | valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + | 499 | valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + |
489 | proveedor.NOM | 500 | proveedor.NOM |
490 | }); | 501 | }); |
491 | }, function() { | 502 | }, function() { |
492 | 503 | ||
493 | } | 504 | } |
494 | ); | 505 | ); |
495 | } | 506 | } |
496 | }; | 507 | }; |
497 | 508 | ||
498 | $scope.seleccionarCliente = function() { | 509 | $scope.seleccionarCliente = function() { |
499 | if(!$scope.notaPedido.vendedor.CodVen) { | 510 | if(!$scope.notaPedido.vendedor.CodVen) { |
500 | focaModalService.alert('Primero seleccione un vendedor'); | 511 | focaModalService.alert('Primero seleccione un vendedor'); |
501 | return; | 512 | return; |
502 | } | 513 | } |
503 | if(validarNotaRemitada()) { | 514 | if(validarNotaRemitada()) { |
504 | var modalInstance = $uibModal.open( | 515 | var modalInstance = $uibModal.open( |
505 | { | 516 | { |
506 | ariaLabelledBy: 'Busqueda de Cliente', | 517 | ariaLabelledBy: 'Busqueda de Cliente', |
507 | templateUrl: 'foca-busqueda-cliente-modal.html', | 518 | templateUrl: 'foca-busqueda-cliente-modal.html', |
508 | controller: 'focaBusquedaClienteModalController', | 519 | controller: 'focaBusquedaClienteModalController', |
509 | resolve: { | 520 | resolve: { |
510 | vendedor: function() { return $scope.notaPedido.vendedor; } | 521 | vendedor: function() { return $scope.notaPedido.vendedor; } |
511 | }, | 522 | }, |
512 | size: 'lg' | 523 | size: 'lg' |
513 | } | 524 | } |
514 | ); | 525 | ); |
515 | modalInstance.result.then( | 526 | modalInstance.result.then( |
516 | function(cliente) { | 527 | function(cliente) { |
517 | $scope.abrirModalDomicilios(cliente); | 528 | $scope.abrirModalDomicilios(cliente); |
518 | $scope.cliente = cliente; | 529 | $scope.cliente = cliente; |
519 | }, function() {} | 530 | }, function() {} |
520 | ); | 531 | ); |
521 | } | 532 | } |
522 | }; | 533 | }; |
523 | 534 | ||
524 | $scope.abrirModalDomicilios = function(cliente) { | 535 | $scope.abrirModalDomicilios = function(cliente) { |
525 | var modalInstanceDomicilio = $uibModal.open( | 536 | var modalInstanceDomicilio = $uibModal.open( |
526 | { | 537 | { |
527 | ariaLabelledBy: 'Busqueda de Domicilios', | 538 | ariaLabelledBy: 'Busqueda de Domicilios', |
528 | templateUrl: 'modal-domicilio.html', | 539 | templateUrl: 'modal-domicilio.html', |
529 | controller: 'focaModalDomicilioController', | 540 | controller: 'focaModalDomicilioController', |
530 | resolve: { | 541 | resolve: { |
531 | idCliente: function() { return cliente.cod; }, | 542 | idCliente: function() { return cliente.cod; }, |
532 | esNuevo: function() { return cliente.esNuevo; } | 543 | esNuevo: function() { return cliente.esNuevo; } |
533 | }, | 544 | }, |
534 | size: 'lg', | 545 | size: 'lg', |
535 | } | 546 | } |
536 | ); | 547 | ); |
537 | modalInstanceDomicilio.result.then( | 548 | modalInstanceDomicilio.result.then( |
538 | function(domicilio) { | 549 | function(domicilio) { |
539 | $scope.notaPedido.domicilio = domicilio; | 550 | $scope.notaPedido.domicilio = domicilio; |
540 | $scope.notaPedido.cliente = { | 551 | $scope.notaPedido.cliente = { |
541 | COD: cliente.cod, | 552 | COD: cliente.cod, |
542 | CUIT: cliente.cuit, | 553 | CUIT: cliente.cuit, |
543 | NOM: cliente.nom | 554 | NOM: cliente.nom |
544 | }; | 555 | }; |
545 | var domicilioStamp = | 556 | var domicilioStamp = |
546 | domicilio.Calle + ' ' + domicilio.Numero + ', ' + | 557 | domicilio.Calle + ' ' + domicilio.Numero + ', ' + |
547 | domicilio.Localidad + ', ' + domicilio.Provincia; | 558 | domicilio.Localidad + ', ' + domicilio.Provincia; |
548 | $scope.notaPedido.domicilioStamp = domicilioStamp; | 559 | $scope.notaPedido.domicilioStamp = domicilioStamp; |
549 | 560 | ||
550 | $scope.notaPedido.puntosDescarga = domicilio.puntosDescarga; | 561 | $scope.notaPedido.puntosDescarga = domicilio.puntosDescarga; |
551 | 562 | ||
552 | $scope.$broadcast('addCabecera', { | 563 | $scope.$broadcast('addCabecera', { |
553 | label: 'Cliente:', | 564 | label: 'Cliente:', |
554 | valor: $filter('rellenarDigitos')(cliente.cod, 5) + ' - ' + cliente.nom | 565 | valor: $filter('rellenarDigitos')(cliente.cod, 5) + ' - ' + cliente.nom |
555 | }); | 566 | }); |
556 | $scope.$broadcast('addCabecera', { | 567 | $scope.$broadcast('addCabecera', { |
557 | label: 'Domicilio:', | 568 | label: 'Domicilio:', |
558 | valor: domicilioStamp | 569 | valor: domicilioStamp |
559 | }); | 570 | }); |
560 | if(domicilio.verPuntos) { | 571 | if(domicilio.verPuntos) { |
561 | delete $scope.notaPedido.domicilio.verPuntos; | 572 | delete $scope.notaPedido.domicilio.verPuntos; |
562 | $scope.seleccionarPuntosDeDescarga(); | 573 | $scope.seleccionarPuntosDeDescarga(); |
563 | }else { | 574 | }else { |
564 | crearNotaPedidoService | 575 | crearNotaPedidoService |
565 | .getPuntosDescargaByClienDom(domicilio.id, cliente.cod) | 576 | .getPuntosDescargaByClienDom(domicilio.id, cliente.cod) |
566 | .then(function(res) { | 577 | .then(function(res) { |
567 | if(res.data.length) $scope.seleccionarPuntosDeDescarga(); | 578 | if(res.data.length) $scope.seleccionarPuntosDeDescarga(); |
568 | }); | 579 | }); |
569 | } | 580 | } |
570 | }, function() { | 581 | }, function() { |
571 | $scope.seleccionarCliente(); | 582 | $scope.seleccionarCliente(); |
572 | return; | 583 | return; |
573 | } | 584 | } |
574 | ); | 585 | ); |
575 | }; | 586 | }; |
576 | 587 | ||
577 | $scope.getTotal = function() { | 588 | $scope.getTotal = function() { |
578 | var total = 0; | 589 | var total = 0; |
579 | var arrayTempArticulos = $scope.articulosTabla; | 590 | var arrayTempArticulos = $scope.articulosTabla; |
580 | for (var i = 0; i < arrayTempArticulos.length; i++) { | 591 | for (var i = 0; i < arrayTempArticulos.length; i++) { |
581 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; | 592 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; |
582 | } | 593 | } |
583 | return parseFloat(total.toFixed(2)); | 594 | return parseFloat(total.toFixed(2)); |
584 | }; | 595 | }; |
585 | 596 | ||
586 | $scope.getSubTotal = function() { | 597 | $scope.getSubTotal = function() { |
587 | if($scope.articuloACargar) { | 598 | if($scope.articuloACargar) { |
588 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; | 599 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; |
589 | } | 600 | } |
590 | }; | 601 | }; |
591 | 602 | ||
592 | $scope.seleccionarPreciosYCondiciones = function() { | 603 | $scope.seleccionarPreciosYCondiciones = function() { |
593 | if(validarNotaRemitada()) { | 604 | if(validarNotaRemitada()) { |
594 | var modalInstance = $uibModal.open( | 605 | var modalInstance = $uibModal.open( |
595 | { | 606 | { |
596 | ariaLabelledBy: 'Busqueda de Precio Condición', | 607 | ariaLabelledBy: 'Busqueda de Precio Condición', |
597 | templateUrl: 'modal-precio-condicion.html', | 608 | templateUrl: 'modal-precio-condicion.html', |
598 | controller: 'focaModalPrecioCondicionController', | 609 | controller: 'focaModalPrecioCondicionController', |
599 | size: 'lg' | 610 | size: 'lg' |
600 | } | 611 | } |
601 | ); | 612 | ); |
602 | modalInstance.result.then( | 613 | modalInstance.result.then( |
603 | function(precioCondicion) { | 614 | function(precioCondicion) { |
604 | var cabecera = ''; | 615 | var cabecera = ''; |
605 | var plazosConcat = ''; | 616 | var plazosConcat = ''; |
606 | if(!Array.isArray(precioCondicion)) { | 617 | if(!Array.isArray(precioCondicion)) { |
607 | $scope.notaPedido.idPrecioCondicion = precioCondicion.id; | 618 | $scope.notaPedido.idPrecioCondicion = precioCondicion.id; |
608 | $scope.plazosPagos = precioCondicion.plazoPago; | 619 | $scope.plazosPagos = precioCondicion.plazoPago; |
609 | $scope.idLista = precioCondicion.idListaPrecio; | 620 | $scope.idLista = precioCondicion.idListaPrecio; |
610 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { | 621 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { |
611 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; | 622 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; |
612 | } | 623 | } |
613 | cabecera = $filter('rellenarDigitos')(precioCondicion.id, 4) + | 624 | cabecera = $filter('rellenarDigitos')(precioCondicion.id, 4) + |
614 | ' - ' + precioCondicion.nombre + ' ' + plazosConcat.trim(); | 625 | ' - ' + precioCondicion.nombre + ' ' + plazosConcat.trim(); |
615 | } else { //Cuando se ingresan los plazos manualmente | 626 | } else { //Cuando se ingresan los plazos manualmente |
616 | $scope.notaPedido.idPrecioCondicion = 0; | 627 | $scope.notaPedido.idPrecioCondicion = 0; |
617 | //-1, el modal productos busca todos los productos | 628 | //-1, el modal productos busca todos los productos |
618 | $scope.idLista = -1; | 629 | $scope.idLista = -1; |
619 | $scope.plazosPagos = precioCondicion; | 630 | $scope.plazosPagos = precioCondicion; |
620 | for(var j = 0; j < precioCondicion.length; j++) { | 631 | for(var j = 0; j < precioCondicion.length; j++) { |
621 | plazosConcat += precioCondicion[j].dias + ' '; | 632 | plazosConcat += precioCondicion[j].dias + ' '; |
622 | } | 633 | } |
623 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); | 634 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); |
624 | } | 635 | } |
625 | $scope.articulosTabla = []; | 636 | $scope.articulosTabla = []; |
626 | $scope.$broadcast('addCabecera', { | 637 | $scope.$broadcast('addCabecera', { |
627 | label: 'Precios y condiciones:', | 638 | label: 'Precios y condiciones:', |
628 | valor: cabecera | 639 | valor: cabecera |
629 | }); | 640 | }); |
630 | }, function() { | 641 | }, function() { |
631 | 642 | ||
632 | } | 643 | } |
633 | ); | 644 | ); |
634 | } | 645 | } |
635 | }; | 646 | }; |
636 | 647 | ||
637 | $scope.seleccionarFlete = function() { | 648 | $scope.seleccionarFlete = function() { |
638 | if(validarNotaRemitada()) { | 649 | if(validarNotaRemitada()) { |
639 | var modalInstance = $uibModal.open( | 650 | var modalInstance = $uibModal.open( |
640 | { | 651 | { |
641 | ariaLabelledBy: 'Busqueda de Flete', | 652 | ariaLabelledBy: 'Busqueda de Flete', |
642 | templateUrl: 'modal-flete.html', | 653 | templateUrl: 'modal-flete.html', |
643 | controller: 'focaModalFleteController', | 654 | controller: 'focaModalFleteController', |
644 | size: 'lg', | 655 | size: 'lg', |
645 | resolve: { | 656 | resolve: { |
646 | parametrosFlete: | 657 | parametrosFlete: |
647 | function() { | 658 | function() { |
648 | return { | 659 | return { |
649 | flete: $scope.notaPedido.fob ? 'FOB' : | 660 | flete: $scope.notaPedido.fob ? 'FOB' : |
650 | ( $scope.notaPedido.flete ? '1' : | 661 | ( $scope.notaPedido.flete ? '1' : |
651 | ($scope.notaPedido.flete === undefined ? | 662 | ($scope.notaPedido.flete === undefined ? |
652 | null : '0')), | 663 | null : '0')), |
653 | bomba: $scope.notaPedido.bomba ? '1' : | 664 | bomba: $scope.notaPedido.bomba ? '1' : |
654 | ($scope.notaPedido.bomba === undefined ? | 665 | ($scope.notaPedido.bomba === undefined ? |
655 | null : '0'), | 666 | null : '0'), |
656 | kilometros: $scope.notaPedido.kilometros | 667 | kilometros: $scope.notaPedido.kilometros |
657 | }; | 668 | }; |
658 | } | 669 | } |
659 | } | 670 | } |
660 | } | 671 | } |
661 | ); | 672 | ); |
662 | modalInstance.result.then( | 673 | modalInstance.result.then( |
663 | function(datos) { | 674 | function(datos) { |
664 | $scope.notaPedido.flete = datos.flete; | 675 | $scope.notaPedido.flete = datos.flete; |
665 | $scope.notaPedido.fob = datos.FOB; | 676 | $scope.notaPedido.fob = datos.FOB; |
666 | $scope.notaPedido.bomba = datos.bomba; | 677 | $scope.notaPedido.bomba = datos.bomba; |
667 | $scope.notaPedido.kilometros = datos.kilometros; | 678 | $scope.notaPedido.kilometros = datos.kilometros; |
668 | $scope.$broadcast('addCabecera', { | 679 | $scope.$broadcast('addCabecera', { |
669 | label: 'Flete:', | 680 | label: 'Flete:', |
670 | valor: datos.FOB ? 'FOB' : (datos.flete ? 'Si' : 'No') | 681 | valor: datos.FOB ? 'FOB' : (datos.flete ? 'Si' : 'No') |
671 | }); | 682 | }); |
672 | if(datos.flete) { | 683 | if(datos.flete) { |
673 | $scope.$broadcast('addCabecera', { | 684 | $scope.$broadcast('addCabecera', { |
674 | label: 'Bomba:', | 685 | label: 'Bomba:', |
675 | valor: datos.bomba ? 'Si' : 'No' | 686 | valor: datos.bomba ? 'Si' : 'No' |
676 | }); | 687 | }); |
677 | $scope.$broadcast('addCabecera', { | 688 | $scope.$broadcast('addCabecera', { |
678 | label: 'Kilometros:', | 689 | label: 'Kilometros:', |
679 | valor: datos.kilometros | 690 | valor: datos.kilometros |
680 | }); | 691 | }); |
681 | } else { | 692 | } else { |
682 | $scope.$broadcast('removeCabecera', 'Bomba:'); | 693 | $scope.$broadcast('removeCabecera', 'Bomba:'); |
683 | $scope.$broadcast('removeCabecera', 'Kilometros:'); | 694 | $scope.$broadcast('removeCabecera', 'Kilometros:'); |
684 | $scope.notaPedido.bomba = false; | 695 | $scope.notaPedido.bomba = false; |
685 | $scope.notaPedido.kilometros = null; | 696 | $scope.notaPedido.kilometros = null; |
686 | } | 697 | } |
687 | }, function() { | 698 | }, function() { |
688 | 699 | ||
689 | } | 700 | } |
690 | ); | 701 | ); |
691 | } | 702 | } |
692 | }; | 703 | }; |
693 | 704 | ||
694 | $scope.seleccionarMoneda = function() { | 705 | $scope.seleccionarMoneda = function() { |
695 | if(validarNotaRemitada()) { | 706 | if(validarNotaRemitada()) { |
696 | var parametrosModal = { | 707 | var parametrosModal = { |
697 | titulo: 'Búsqueda de monedas', | 708 | titulo: 'Búsqueda de monedas', |
698 | query: '/moneda', | 709 | query: '/moneda', |
699 | columnas: [ | 710 | columnas: [ |
700 | { | 711 | { |
701 | propiedad: 'DETALLE', | 712 | propiedad: 'DETALLE', |
702 | nombre: 'Nombre' | 713 | nombre: 'Nombre' |
703 | }, | 714 | }, |
704 | { | 715 | { |
705 | propiedad: 'SIMBOLO', | 716 | propiedad: 'SIMBOLO', |
706 | nombre: 'Símbolo' | 717 | nombre: 'Símbolo' |
707 | } | 718 | } |
708 | ], | 719 | ], |
709 | size: 'md' | 720 | size: 'md' |
710 | }; | 721 | }; |
711 | focaModalService.modal(parametrosModal).then( | 722 | focaModalService.modal(parametrosModal).then( |
712 | function(moneda) { | 723 | function(moneda) { |
713 | $scope.abrirModalCotizacion(moneda); | 724 | $scope.abrirModalCotizacion(moneda); |
714 | }, function() { | 725 | }, function() { |
715 | 726 | ||
716 | } | 727 | } |
717 | ); | 728 | ); |
718 | } | 729 | } |
719 | }; | 730 | }; |
720 | 731 | ||
721 | $scope.abrirModalCotizacion = function(moneda) { | 732 | $scope.abrirModalCotizacion = function(moneda) { |
722 | var modalInstance = $uibModal.open( | 733 | var modalInstance = $uibModal.open( |
723 | { | 734 | { |
724 | ariaLabelledBy: 'Busqueda de Cotización', | 735 | ariaLabelledBy: 'Busqueda de Cotización', |
725 | templateUrl: 'modal-cotizacion.html', | 736 | templateUrl: 'modal-cotizacion.html', |
726 | controller: 'focaModalCotizacionController', | 737 | controller: 'focaModalCotizacionController', |
727 | size: 'lg', | 738 | size: 'lg', |
728 | resolve: {idMoneda: function() {return moneda.ID;}} | 739 | resolve: {idMoneda: function() {return moneda.ID;}} |
729 | } | 740 | } |
730 | ); | 741 | ); |
731 | modalInstance.result.then( | 742 | modalInstance.result.then( |
732 | function(cotizacion) { | 743 | function(cotizacion) { |
733 | var articulosTablaTemp = $scope.articulosTabla; | 744 | var articulosTablaTemp = $scope.articulosTabla; |
734 | for(var i = 0; i < articulosTablaTemp.length; i++) { | 745 | for(var i = 0; i < articulosTablaTemp.length; i++) { |
735 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * | 746 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * |
736 | $scope.notaPedido.cotizacion.VENDEDOR; | 747 | $scope.notaPedido.cotizacion.VENDEDOR; |
737 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / | 748 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / |
738 | cotizacion.VENDEDOR; | 749 | cotizacion.VENDEDOR; |
739 | } | 750 | } |
740 | $scope.articulosTabla = articulosTablaTemp; | 751 | $scope.articulosTabla = articulosTablaTemp; |
741 | $scope.notaPedido.moneda = moneda; | 752 | $scope.notaPedido.moneda = moneda; |
742 | $scope.notaPedido.cotizacion = cotizacion; | 753 | $scope.notaPedido.cotizacion = cotizacion; |
743 | if(moneda.DETALLE === 'PESOS ARGENTINOS') { | 754 | if(moneda.DETALLE === 'PESOS ARGENTINOS') { |
744 | $scope.$broadcast('removeCabecera', 'Moneda:'); | 755 | $scope.$broadcast('removeCabecera', 'Moneda:'); |
745 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); | 756 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); |
746 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); | 757 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); |
747 | }else { | 758 | }else { |
748 | $scope.$broadcast('addCabecera', { | 759 | $scope.$broadcast('addCabecera', { |
749 | label: 'Moneda:', | 760 | label: 'Moneda:', |
750 | valor: moneda.DETALLE | 761 | valor: moneda.DETALLE |
751 | }); | 762 | }); |
752 | $scope.$broadcast('addCabecera', { | 763 | $scope.$broadcast('addCabecera', { |
753 | label: 'Fecha cotizacion:', | 764 | label: 'Fecha cotizacion:', |
754 | valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') | 765 | valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') |
755 | }); | 766 | }); |
756 | $scope.$broadcast('addCabecera', { | 767 | $scope.$broadcast('addCabecera', { |
757 | label: 'Cotizacion:', | 768 | label: 'Cotizacion:', |
758 | valor: $filter('number')(cotizacion.VENDEDOR, '2') | 769 | valor: $filter('number')(cotizacion.VENDEDOR, '2') |
759 | }); | 770 | }); |
760 | } | 771 | } |
761 | }, function() { | 772 | }, function() { |
762 | 773 | ||
763 | } | 774 | } |
764 | ); | 775 | ); |
765 | }; | 776 | }; |
766 | 777 | ||
767 | $scope.agregarATabla = function(key) { | 778 | $scope.agregarATabla = function(key) { |
768 | if(key === 13) { | 779 | if(key === 13) { |
769 | if($scope.articuloACargar.cantidad === undefined || | 780 | if($scope.articuloACargar.cantidad === undefined || |
770 | $scope.articuloACargar.cantidad === 0 || | 781 | $scope.articuloACargar.cantidad === 0 || |
771 | $scope.articuloACargar.cantidad === null ) { | 782 | $scope.articuloACargar.cantidad === null ) { |
772 | focaModalService.alert('El valor debe ser al menos 1'); | 783 | focaModalService.alert('El valor debe ser al menos 1'); |
773 | return; | 784 | return; |
774 | } | 785 | } |
775 | delete $scope.articuloACargar.sectorCodigo; | 786 | delete $scope.articuloACargar.sectorCodigo; |
776 | $scope.articulosTabla.push($scope.articuloACargar); | 787 | $scope.articulosTabla.push($scope.articuloACargar); |
777 | $scope.cargando = true; | 788 | $scope.cargando = true; |
778 | } | 789 | } |
779 | }; | 790 | }; |
780 | 791 | ||
781 | $scope.quitarArticulo = function(key) { | 792 | $scope.quitarArticulo = function(key) { |
782 | $scope.articulosTabla.splice(key, 1); | 793 | $scope.articulosTabla.splice(key, 1); |
783 | }; | 794 | }; |
784 | 795 | ||
785 | $scope.editarArticulo = function(key, articulo) { | 796 | $scope.editarArticulo = function(key, articulo) { |
786 | if(key === 13) { | 797 | if(key === 13) { |
787 | if(articulo.cantidad === null || articulo.cantidad === 0 || | 798 | if(articulo.cantidad === null || articulo.cantidad === 0 || |
788 | articulo.cantidad === undefined) { | 799 | articulo.cantidad === undefined) { |
789 | focaModalService.alert('El valor debe ser al menos 1'); | 800 | focaModalService.alert('El valor debe ser al menos 1'); |
790 | return; | 801 | return; |
791 | } | 802 | } |
792 | articulo.editCantidad = false; | 803 | articulo.editCantidad = false; |
793 | articulo.editPrecio = false; | 804 | articulo.editPrecio = false; |
794 | } | 805 | } |
795 | }; | 806 | }; |
796 | 807 | ||
797 | $scope.cambioEdit = function(articulo, propiedad) { | 808 | $scope.cambioEdit = function(articulo, propiedad) { |
798 | if(propiedad === 'cantidad') { | 809 | if(propiedad === 'cantidad') { |
799 | articulo.editCantidad = true; | 810 | articulo.editCantidad = true; |
800 | } else if(propiedad === 'precio') { | 811 | } else if(propiedad === 'precio') { |
801 | articulo.editPrecio = true; | 812 | articulo.editPrecio = true; |
802 | } | 813 | } |
803 | }; | 814 | }; |
804 | 815 | ||
805 | $scope.resetFilter = function() { | 816 | $scope.resetFilter = function() { |
806 | $scope.articuloACargar = {}; | 817 | $scope.articuloACargar = {}; |
807 | $scope.cargando = true; | 818 | $scope.cargando = true; |
808 | }; | 819 | }; |
809 | //Recibe aviso si el teclado está en uso | 820 | //Recibe aviso si el teclado está en uso |
810 | $rootScope.$on('usarTeclado', function(event, data) { | 821 | $rootScope.$on('usarTeclado', function(event, data) { |
811 | if(data) { | 822 | if(data) { |
812 | $scope.mostrarTeclado = true; | 823 | $scope.mostrarTeclado = true; |
813 | return; | 824 | return; |
814 | } | 825 | } |
815 | $scope.mostrarTeclado = false; | 826 | $scope.mostrarTeclado = false; |
816 | }); | 827 | }); |
817 | 828 | ||
818 | $scope.selectFocus = function($event) { | 829 | $scope.selectFocus = function($event) { |
819 | // Si el teclado esta en uso no selecciona el valor | 830 | // Si el teclado esta en uso no selecciona el valor |
820 | if($scope.mostrarTeclado) { | 831 | if($scope.mostrarTeclado) { |
821 | return; | 832 | return; |
822 | } | 833 | } |
823 | $event.target.select(); | 834 | $event.target.select(); |
824 | }; | 835 | }; |
825 | 836 | ||
826 | $scope.salir = function() { | 837 | $scope.salir = function() { |
827 | $location.path('/'); | 838 | $location.path('/'); |
828 | }; | 839 | }; |
829 | 840 | ||
830 | $scope.parsearATexto = function(articulo) { | 841 | $scope.parsearATexto = function(articulo) { |
831 | articulo.cantidad = parseFloat(articulo.cantidad); | 842 | articulo.cantidad = parseFloat(articulo.cantidad); |
832 | articulo.precio = parseFloat(articulo.precio); | 843 | articulo.precio = parseFloat(articulo.precio); |
833 | }; | 844 | }; |
834 | 845 | ||
835 | function addArrayCabecera(array) { | 846 | function addArrayCabecera(array) { |
836 | for(var i = 0; i < array.length; i++) { | 847 | for(var i = 0; i < array.length; i++) { |
837 | $scope.$broadcast('addCabecera', { | 848 | $scope.$broadcast('addCabecera', { |
838 | label: array[i].label, | 849 | label: array[i].label, |
839 | valor: array[i].valor | 850 | valor: array[i].valor |
840 | }); | 851 | }); |
841 | } | 852 | } |
842 | } | 853 | } |
843 | 854 | ||
844 | function rellenar(relleno, longitud) { | 855 | function rellenar(relleno, longitud) { |
845 | relleno = '' + relleno; | 856 | relleno = '' + relleno; |
846 | while (relleno.length < longitud) { | 857 | while (relleno.length < longitud) { |
847 | relleno = '0' + relleno; | 858 | relleno = '0' + relleno; |
848 | } | 859 | } |
849 | 860 | ||
850 | return relleno; | 861 | return relleno; |
851 | } | 862 | } |
852 | 863 | ||
853 | function validarNotaRemitada() { | 864 | function validarNotaRemitada() { |
854 | if(!$scope.notaPedido.idRemito) { | 865 | if(!$scope.notaPedido.idRemito) { |
855 | return true; | 866 | return true; |
856 | }else{ | 867 | }else{ |
857 | focaModalService.alert('No se puede editar una nota de pedido remitada'); | 868 | focaModalService.alert('No se puede editar una nota de pedido remitada'); |
858 | return false; | 869 | return false; |
859 | } | 870 | } |
860 | } | 871 | } |
861 | function formatearPuntosDescarga(puntosDescarga) { | 872 | function formatearPuntosDescarga(puntosDescarga) { |
862 | var result = []; | 873 | var result = []; |
863 | 874 | ||
864 | puntosDescarga.forEach(function(el) { | 875 | puntosDescarga.forEach(function(el) { |
865 | var puntoDescarga = result.filter(function(resultPunto) { | 876 | var puntoDescarga = result.filter(function(resultPunto) { |
866 | return resultPunto.id == el.idPuntoDescarga; | 877 | return resultPunto.id == el.idPuntoDescarga; |
867 | }); | 878 | }); |
868 | 879 | ||
869 | if(puntoDescarga.length) { | 880 | if(puntoDescarga.length) { |
870 | puntoDescarga[0].articulosAgregados.push({ | 881 | puntoDescarga[0].articulosAgregados.push({ |
871 | cantidad: el.cantidad, | 882 | cantidad: el.cantidad, |
872 | descripcion: el.producto.descripcion, | 883 | descripcion: el.producto.descripcion, |
873 | id: el.producto.id | 884 | id: el.producto.id |
874 | }); | 885 | }); |
875 | }else { | 886 | }else { |
876 | result.push({ | 887 | result.push({ |
877 | id: el.puntoDescarga.id, | 888 | id: el.puntoDescarga.id, |
878 | id_cliente: el.puntoDescarga.id_cliente, | 889 | id_cliente: el.puntoDescarga.id_cliente, |
879 | id_da_config_0: el.puntoDescarga.id_da_config_0, | 890 | id_da_config_0: el.puntoDescarga.id_da_config_0, |
880 | latitud: el.puntoDescarga.latitud, | 891 | latitud: el.puntoDescarga.latitud, |
881 | longitud: el.puntoDescarga.longitud, | 892 | longitud: el.puntoDescarga.longitud, |
882 | descripcion: el.puntoDescarga.descripcion, | 893 | descripcion: el.puntoDescarga.descripcion, |
883 | articulosAgregados: [ | 894 | articulosAgregados: [ |
884 | { | 895 | { |
885 | cantidad: el.cantidad, | 896 | cantidad: el.cantidad, |
886 | descripcion: el.producto.descripcion, | 897 | descripcion: el.producto.descripcion, |
887 | id: el.producto.id | 898 | id: el.producto.id |
888 | } | 899 | } |
889 | ] | 900 | ] |
890 | }); | 901 | }); |
891 | } | 902 | } |
892 | }); | 903 | }); |
893 | return result; | 904 | return result; |
894 | } | 905 | } |
895 | 906 | ||
896 | function salir() { | 907 | function salir() { |
897 | var notaPedido = { | 908 | var notaPedido = { |
898 | id: 0, | 909 | id: 0, |
899 | vendedor: {}, | 910 | vendedor: {}, |
900 | cliente: {}, | 911 | cliente: {}, |
901 | proveedor: {}, | 912 | proveedor: {}, |
902 | domicilio: {dom: ''}, | 913 | domicilio: {dom: ''}, |
903 | moneda: $scope.notaPedido.moneda, | 914 | moneda: $scope.notaPedido.moneda, |
904 | cotizacion: $scope.notaPedido.cotizacion | 915 | cotizacion: $scope.notaPedido.cotizacion |
905 | }; | 916 | }; |
906 | if(JSON.stringify($scope.notaPedido) !== JSON.stringify(notaPedido)) { | 917 | if(JSON.stringify($scope.notaPedido) !== JSON.stringify(notaPedido)) { |
907 | focaModalService | 918 | focaModalService |
908 | .confirm('¿Esta seguro de que desea salir? ' + | 919 | .confirm('¿Esta seguro de que desea salir? ' + |
909 | 'Se perderán todos los datos cargados.') | 920 | 'Se perderán todos los datos cargados.') |
910 | .then(function(data) { | 921 | .then(function(data) { |
911 | if(data) $location.path('/'); | 922 | if(data) $location.path('/'); |
912 | }); | 923 | }); |
913 | }else { | 924 | }else { |
914 | $location.path('/'); | 925 | $location.path('/'); |
915 | } | 926 | } |
916 | } | 927 | } |
917 | } | 928 | } |
918 | ]); | 929 | ]); |
919 | 930 |