Commit e4c0f65364ee6a71bef71910568c9d977f70e6c8
Exists in
master
Merge remote-tracking branch 'upstream/develop'
Showing
3 changed files
Show diff stats
spec/controllerSpec.js
| 1 | describe('Controladores módulo crear hoja de ruta', function() { | 1 | describe('Controladores módulo crear hoja de ruta', function() { |
| 2 | 2 | ||
| 3 | var $controller; | 3 | var $controller; |
| 4 | 4 | ||
| 5 | beforeEach(function() { | 5 | beforeEach(function() { |
| 6 | 6 | ||
| 7 | module('focaCrearHojaRuta'); | 7 | module('focaCrearHojaRuta'); |
| 8 | inject(function(_$controller_) { | 8 | inject(function(_$controller_) { |
| 9 | $controller = _$controller_; | 9 | $controller = _$controller_; |
| 10 | }); | 10 | }); |
| 11 | }); | 11 | }); |
| 12 | 12 | ||
| 13 | describe('controlador focaModalDatosHojaRutaCtrl', function() { | 13 | describe('controlador focaModalDatosHojaRutaCtrl', function() { |
| 14 | 14 | ||
| 15 | it('Existe el controlador focaModalDatosHojaRutaCtrl', function() { | 15 | it('Existe el controlador focaModalDatosHojaRutaCtrl', function() { |
| 16 | 16 | ||
| 17 | //act | 17 | //act |
| 18 | var controlador = $controller('focaModalDatosHojaRutaCtrl', { | 18 | var controlador = $controller('focaModalDatosHojaRutaCtrl', { |
| 19 | $filter: {}, | 19 | $filter: {}, |
| 20 | $scope: {}, | 20 | $scope: {}, |
| 21 | $uibModalInstance: {}, | 21 | $uibModalInstance: {}, |
| 22 | focaModalService: {}, | 22 | focaModalService: {}, |
| 23 | parametrosDatos: {} | 23 | parametrosDatos: {} |
| 24 | }); | 24 | }); |
| 25 | 25 | ||
| 26 | //assert | 26 | //assert |
| 27 | expect(typeof controlador).toEqual('object'); | 27 | expect(typeof controlador).toEqual('object'); |
| 28 | }); | 28 | }); |
| 29 | 29 | ||
| 30 | it('función $scope.aceptar muestra alerta cuando el formulario es inválido', function() { | 30 | it('función $scope.aceptar muestra alerta cuando el formulario es inválido', function() { |
| 31 | 31 | ||
| 32 | //arrange | 32 | //arrange |
| 33 | var scope = {}; | 33 | var scope = {}; |
| 34 | var focaModalService = { | 34 | var focaModalService = { |
| 35 | alert: function() { } | 35 | alert: function() { } |
| 36 | }; | 36 | }; |
| 37 | 37 | ||
| 38 | $controller('focaModalDatosHojaRutaCtrl', { | 38 | $controller('focaModalDatosHojaRutaCtrl', { |
| 39 | $filter: {}, | 39 | $filter: {}, |
| 40 | $scope: scope, | 40 | $scope: scope, |
| 41 | $uibModalInstance: {}, | 41 | $uibModalInstance: {}, |
| 42 | focaModalService: focaModalService, | 42 | focaModalService: focaModalService, |
| 43 | parametrosDatos: {} | 43 | parametrosDatos: {} |
| 44 | }); | 44 | }); |
| 45 | 45 | ||
| 46 | //act | 46 | //act |
| 47 | scope.formDatosHojaRuta = { | 47 | scope.formDatosHojaRuta = { |
| 48 | $valid: false | 48 | $valid: false |
| 49 | }; | 49 | }; |
| 50 | spyOn(focaModalService, 'alert'); | 50 | spyOn(focaModalService, 'alert'); |
| 51 | scope.aceptar(13); | 51 | scope.aceptar(13); |
| 52 | 52 | ||
| 53 | //assert | 53 | //assert |
| 54 | expect(focaModalService.alert).toHaveBeenCalledWith('Formulario inválido'); | 54 | expect(focaModalService.alert).toHaveBeenCalledWith('Formulario inválido'); |
| 55 | }); | 55 | }); |
| 56 | 56 | ||
| 57 | it('función $scope.aceptar llama a uibModalInstance.close', function() { | 57 | it('función $scope.aceptar llama a uibModalInstance.close', function() { |
| 58 | 58 | ||
| 59 | //arrange | 59 | //arrange |
| 60 | var scope = {}; | 60 | var scope = {}; |
| 61 | var uibModalInstance = { | 61 | var uibModalInstance = { |
| 62 | close: function() { } | 62 | close: function() { } |
| 63 | }; | 63 | }; |
| 64 | 64 | ||
| 65 | $controller('focaModalDatosHojaRutaCtrl', { | 65 | $controller('focaModalDatosHojaRutaCtrl', { |
| 66 | $filter: {}, | 66 | $filter: {}, |
| 67 | $scope: scope, | 67 | $scope: scope, |
| 68 | $uibModalInstance: uibModalInstance, | 68 | $uibModalInstance: uibModalInstance, |
| 69 | focaModalService: {}, | 69 | focaModalService: {}, |
| 70 | parametrosDatos: {} | 70 | parametrosDatos: {} |
| 71 | }); | 71 | }); |
| 72 | 72 | ||
| 73 | //act | 73 | //act |
| 74 | scope.formDatosHojaRuta = { | 74 | scope.formDatosHojaRuta = { |
| 75 | $valid: true | 75 | $valid: true |
| 76 | }; | 76 | }; |
| 77 | spyOn(uibModalInstance, 'close'); | 77 | spyOn(uibModalInstance, 'close'); |
| 78 | scope.aceptar(13); | 78 | scope.aceptar(13); |
| 79 | 79 | ||
| 80 | //assert | 80 | //assert |
| 81 | expect(uibModalInstance.close).toHaveBeenCalled(); | 81 | expect(uibModalInstance.close).toHaveBeenCalled(); |
| 82 | }); | 82 | }); |
| 83 | 83 | ||
| 84 | it('función $scope.next suma uno a focused', function() { | 84 | it('función $scope.next suma uno a focused', function() { |
| 85 | 85 | ||
| 86 | //arrange | 86 | //arrange |
| 87 | var scope = {}; | 87 | var scope = {}; |
| 88 | 88 | ||
| 89 | $controller('focaModalDatosHojaRutaCtrl', { | 89 | $controller('focaModalDatosHojaRutaCtrl', { |
| 90 | $filter: {}, | 90 | $filter: {}, |
| 91 | $scope: scope, | 91 | $scope: scope, |
| 92 | $uibModalInstance: {}, | 92 | $uibModalInstance: {}, |
| 93 | focaModalService: {}, | 93 | focaModalService: {}, |
| 94 | parametrosDatos: {} | 94 | parametrosDatos: {} |
| 95 | }); | 95 | }); |
| 96 | scope.focused = 1; | 96 | scope.focused = 1; |
| 97 | 97 | ||
| 98 | //act | 98 | //act |
| 99 | var esperado = scope.focused + 1; | 99 | var esperado = scope.focused + 1; |
| 100 | scope.next(13); | 100 | scope.next(13); |
| 101 | 101 | ||
| 102 | //assert | 102 | //assert |
| 103 | expect(scope.focused).toEqual(esperado); | 103 | expect(scope.focused).toEqual(esperado); |
| 104 | }); | 104 | }); |
| 105 | 105 | ||
| 106 | it('función $scope.cancel llama a dismiss', function() { | 106 | it('función $scope.cancel llama a dismiss', function() { |
| 107 | 107 | ||
| 108 | //arrange | 108 | //arrange |
| 109 | var scope = {}; | 109 | var scope = {}; |
| 110 | var uibModalInstance = { | 110 | var uibModalInstance = { |
| 111 | dismiss: function() { } | 111 | dismiss: function() { } |
| 112 | }; | 112 | }; |
| 113 | 113 | ||
| 114 | $controller('focaModalDatosHojaRutaCtrl', { | 114 | $controller('focaModalDatosHojaRutaCtrl', { |
| 115 | $filter: {}, | 115 | $filter: {}, |
| 116 | $scope: scope, | 116 | $scope: scope, |
| 117 | $uibModalInstance: uibModalInstance, | 117 | $uibModalInstance: uibModalInstance, |
| 118 | focaModalService: {}, | 118 | focaModalService: {}, |
| 119 | parametrosDatos: {} | 119 | parametrosDatos: {} |
| 120 | }); | 120 | }); |
| 121 | 121 | ||
| 122 | //act | 122 | //act |
| 123 | spyOn(uibModalInstance, 'dismiss'); | 123 | spyOn(uibModalInstance, 'dismiss'); |
| 124 | scope.cancel(); | 124 | scope.cancel(); |
| 125 | 125 | ||
| 126 | //assert | 126 | //assert |
| 127 | expect(uibModalInstance.dismiss).toHaveBeenCalledWith('cancel'); | 127 | expect(uibModalInstance.dismiss).toHaveBeenCalledWith('cancel'); |
| 128 | }); | 128 | }); |
| 129 | }); | 129 | }); |
| 130 | 130 | ||
| 131 | describe('controlador hojaRutaCtrl', function() { | 131 | describe('controlador hojaRutaCtrl', function() { |
| 132 | 132 | ||
| 133 | var $filter = function() { | 133 | var $filter = function() { |
| 134 | return function() { }; | 134 | return function() { }; |
| 135 | }; | 135 | }; |
| 136 | 136 | ||
| 137 | var $timeout = function() { }; | 137 | var $timeout = function() { }; |
| 138 | 138 | ||
| 139 | it('existe el controlador hojaRutaCtrl', function() { | 139 | it('existe el controlador hojaRutaCtrl', function() { |
| 140 | 140 | ||
| 141 | //act | 141 | //act |
| 142 | var controlador = $controller('hojaRutaCtrl', { | 142 | var controlador = $controller('hojaRutaCtrl', { |
| 143 | $scope: { | 143 | $scope: { |
| 144 | $broadcast: function() { }, | 144 | $broadcast: function() { }, |
| 145 | $watch: function() {} | 145 | $watch: function() {} |
| 146 | }, | 146 | }, |
| 147 | $uibModal: {}, | 147 | $uibModal: {}, |
| 148 | $location: {}, | 148 | $location: {}, |
| 149 | $filter: $filter, | 149 | $filter: $filter, |
| 150 | $timeout: $timeout, | 150 | $timeout: $timeout, |
| 151 | focaCrearHojaRutaService: { | 151 | focaCrearHojaRutaService: { |
| 152 | getBotonera: function() { }, | 152 | getBotonera: function() { }, |
| 153 | getNumeroHojaRuta: function() { | 153 | getNumeroHojaRuta: function() { |
| 154 | return { | 154 | return { |
| 155 | then: function() { } | 155 | then: function() { } |
| 156 | }; | 156 | }; |
| 157 | }, | ||
| 158 | getParametros: function () { | ||
| 159 | return { | ||
| 160 | then: function() { } | ||
| 161 | }; | ||
| 157 | } | 162 | } |
| 158 | }, | 163 | }, |
| 159 | focaModalService: {}, | 164 | focaModalService: {}, |
| 160 | focaBotoneraLateralService: {}, | 165 | focaBotoneraLateralService: {}, |
| 161 | focaLoginService: {}, | 166 | focaLoginService: {}, |
| 162 | $localStorage: function() {} | 167 | $localStorage: function() {} |
| 163 | }); | 168 | }); |
| 164 | 169 | ||
| 165 | //assert | 170 | //assert |
| 166 | expect(typeof controlador).toEqual('object'); | 171 | expect(typeof controlador).toEqual('object'); |
| 167 | }); | 172 | }); |
| 168 | 173 | ||
| 169 | it('guardar hoja ruta valida que tenga al menos un remito', function() { | 174 | it('guardar hoja ruta valida que tenga al menos un remito', function() { |
| 170 | 175 | ||
| 171 | //arrange | 176 | //arrange |
| 172 | var scope = { | 177 | var scope = { |
| 173 | $broadcast: function() { }, | 178 | $broadcast: function() { }, |
| 174 | $watch: function() {} | 179 | $watch: function() {} |
| 175 | }; | 180 | }; |
| 176 | var focaModalService = { | 181 | var focaModalService = { |
| 177 | alert: function() { } | 182 | alert: function() { } |
| 178 | }; | 183 | }; |
| 179 | 184 | ||
| 180 | $controller('hojaRutaCtrl', { | 185 | $controller('hojaRutaCtrl', { |
| 181 | $scope: scope, | 186 | $scope: scope, |
| 182 | $uibModal: {}, | 187 | $uibModal: {}, |
| 183 | $location: {}, | 188 | $location: {}, |
| 184 | $filter: $filter, | 189 | $filter: $filter, |
| 185 | $timeout: $timeout, | 190 | $timeout: $timeout, |
| 186 | focaCrearHojaRutaService: { | 191 | focaCrearHojaRutaService: { |
| 187 | getBotonera: function() { }, | 192 | getBotonera: function() { }, |
| 188 | getNumeroHojaRuta: function() { | 193 | getNumeroHojaRuta: function() { |
| 189 | return { | 194 | return { |
| 190 | then: function() { } | 195 | then: function() { } |
| 191 | }; | 196 | }; |
| 197 | }, | ||
| 198 | getParametros: function () { | ||
| 199 | return { | ||
| 200 | then: function() { } | ||
| 201 | }; | ||
| 192 | } | 202 | } |
| 193 | }, | 203 | }, |
| 194 | focaModalService: focaModalService, | 204 | focaModalService: focaModalService, |
| 195 | focaBotoneraLateralService: {}, | 205 | focaBotoneraLateralService: {}, |
| 196 | focaLoginService: {}, | 206 | focaLoginService: {}, |
| 197 | $localStorage: function() {} | 207 | $localStorage: function() {} |
| 198 | }); | 208 | }); |
| 199 | scope.remitosTabla = []; | 209 | scope.remitosTabla = []; |
| 200 | 210 | ||
| 201 | //act | 211 | //act |
| 202 | spyOn(focaModalService, 'alert'); | 212 | spyOn(focaModalService, 'alert'); |
| 203 | 213 | ||
| 204 | scope.crearHojaRuta(); | 214 | scope.crearHojaRuta(); |
| 205 | 215 | ||
| 206 | //assert | 216 | //assert |
| 207 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Remitos'); | 217 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Remitos'); |
| 208 | }); | 218 | }); |
| 209 | 219 | ||
| 210 | it('guardar hoja ruta valida que tenga chofer', function() { | 220 | it('guardar hoja ruta valida que tenga chofer', function() { |
| 211 | 221 | ||
| 212 | //arrange | 222 | //arrange |
| 213 | var scope = { | 223 | var scope = { |
| 214 | $broadcast: function() { }, | 224 | $broadcast: function() { }, |
| 215 | $watch: function() {} | 225 | $watch: function() {} |
| 216 | }; | 226 | }; |
| 217 | var focaModalService = { | 227 | var focaModalService = { |
| 218 | alert: function() { } | 228 | alert: function() { } |
| 219 | }; | 229 | }; |
| 220 | 230 | ||
| 221 | $controller('hojaRutaCtrl', { | 231 | $controller('hojaRutaCtrl', { |
| 222 | $scope: scope, | 232 | $scope: scope, |
| 223 | $uibModal: {}, | 233 | $uibModal: {}, |
| 224 | $location: {}, | 234 | $location: {}, |
| 225 | $filter: $filter, | 235 | $filter: $filter, |
| 226 | $timeout: $timeout, | 236 | $timeout: $timeout, |
| 227 | focaCrearHojaRutaService: { | 237 | focaCrearHojaRutaService: { |
| 228 | getBotonera: function() { }, | 238 | getBotonera: function() { }, |
| 229 | getNumeroHojaRuta: function() { | 239 | getNumeroHojaRuta: function() { |
| 230 | return { | 240 | return { |
| 231 | then: function() { } | 241 | then: function() { } |
| 232 | }; | 242 | }; |
| 243 | }, | ||
| 244 | getParametros: function () { | ||
| 245 | return { | ||
| 246 | then: function() { } | ||
| 247 | }; | ||
| 233 | } | 248 | } |
| 234 | }, | 249 | }, |
| 235 | focaModalService: focaModalService, | 250 | focaModalService: focaModalService, |
| 236 | focaBotoneraLateralService: {}, | 251 | focaBotoneraLateralService: {}, |
| 237 | focaLoginService: {}, | 252 | focaLoginService: {}, |
| 238 | $localStorage: function() {} | 253 | $localStorage: function() {} |
| 239 | }); | 254 | }); |
| 240 | 255 | ||
| 241 | scope.hojaRuta = { | 256 | scope.hojaRuta = { |
| 242 | chofer: { }, | 257 | chofer: { }, |
| 243 | remitosTabla: [1] | 258 | remitosTabla: [1] |
| 244 | }; | 259 | }; |
| 245 | 260 | ||
| 246 | //act | 261 | //act |
| 247 | spyOn(focaModalService, 'alert'); | 262 | spyOn(focaModalService, 'alert'); |
| 248 | 263 | ||
| 249 | scope.crearHojaRuta(); | 264 | scope.crearHojaRuta(); |
| 250 | 265 | ||
| 251 | //assert | 266 | //assert |
| 252 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Chofer'); | 267 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Chofer'); |
| 253 | }); | 268 | }); |
| 254 | 269 | ||
| 255 | it('guardar hoja ruta valida que tenga vehiculo', function() { | 270 | it('guardar hoja ruta valida que tenga vehiculo', function() { |
| 256 | 271 | ||
| 257 | //arrange | 272 | //arrange |
| 258 | var scope = { | 273 | var scope = { |
| 259 | $broadcast: function() { }, | 274 | $broadcast: function() { }, |
| 260 | $watch: function() {} | 275 | $watch: function() {} |
| 261 | }; | 276 | }; |
| 262 | var focaModalService = { | 277 | var focaModalService = { |
| 263 | alert: function() { } | 278 | alert: function() { } |
| 264 | }; | 279 | }; |
| 265 | 280 | ||
| 266 | $controller('hojaRutaCtrl', { | 281 | $controller('hojaRutaCtrl', { |
| 267 | $scope: scope, | 282 | $scope: scope, |
| 268 | $uibModal: {}, | 283 | $uibModal: {}, |
| 269 | $location: {}, | 284 | $location: {}, |
| 270 | $filter: $filter, | 285 | $filter: $filter, |
| 271 | $timeout: $timeout, | 286 | $timeout: $timeout, |
| 272 | focaCrearHojaRutaService: { | 287 | focaCrearHojaRutaService: { |
| 273 | getBotonera: function() { }, | 288 | getBotonera: function() { }, |
| 274 | getNumeroHojaRuta: function() { | 289 | getNumeroHojaRuta: function() { |
| 275 | return { | 290 | return { |
| 276 | then: function() { } | 291 | then: function() { } |
| 277 | }; | 292 | }; |
| 293 | }, | ||
| 294 | getParametros: function () { | ||
| 295 | return { | ||
| 296 | then: function() { } | ||
| 297 | }; | ||
| 278 | } | 298 | } |
| 279 | }, | 299 | }, |
| 280 | focaModalService: focaModalService, | 300 | focaModalService: focaModalService, |
| 281 | focaBotoneraLateralService: {}, | 301 | focaBotoneraLateralService: {}, |
| 282 | focaLoginService: {}, | 302 | focaLoginService: {}, |
| 283 | $localStorage: function() {} | 303 | $localStorage: function() {} |
| 284 | }); | 304 | }); |
| 285 | scope.hojaRuta = { | 305 | scope.hojaRuta = { |
| 286 | chofer: { id: true }, | 306 | chofer: { id: true }, |
| 287 | vehiculo: { }, | 307 | vehiculo: { }, |
| 288 | remitosTabla: [1] | 308 | remitosTabla: [1] |
| 289 | }; | 309 | }; |
| 290 | 310 | ||
| 291 | //act | 311 | //act |
| 292 | spyOn(focaModalService, 'alert'); | 312 | spyOn(focaModalService, 'alert'); |
| 293 | 313 | ||
| 294 | scope.crearHojaRuta(); | 314 | scope.crearHojaRuta(); |
| 295 | 315 | ||
| 296 | //assert | 316 | //assert |
| 297 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Vehiculo'); | 317 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Vehiculo'); |
| 298 | }); | 318 | }); |
| 299 | 319 | ||
| 300 | it('guardar hoja ruta valida que tenga transportista', function() { | 320 | it('guardar hoja ruta valida que tenga transportista', function() { |
| 301 | 321 | ||
| 302 | //arrange | 322 | //arrange |
| 303 | var scope = { | 323 | var scope = { |
| 304 | $broadcast: function() { }, | 324 | $broadcast: function() { }, |
| 305 | $watch: function() {} | 325 | $watch: function() {} |
| 306 | }; | 326 | }; |
| 307 | var focaModalService = { | 327 | var focaModalService = { |
| 308 | alert: function() { } | 328 | alert: function() { } |
| 309 | }; | 329 | }; |
| 310 | 330 | ||
| 311 | $controller('hojaRutaCtrl', { | 331 | $controller('hojaRutaCtrl', { |
| 312 | $scope: scope, | 332 | $scope: scope, |
| 313 | $uibModal: {}, | 333 | $uibModal: {}, |
| 314 | $location: {}, | 334 | $location: {}, |
| 315 | $filter: $filter, | 335 | $filter: $filter, |
| 316 | $timeout: $timeout, | 336 | $timeout: $timeout, |
| 317 | focaCrearHojaRutaService: { | 337 | focaCrearHojaRutaService: { |
| 318 | getBotonera: function() { }, | 338 | getBotonera: function() { }, |
| 319 | getNumeroHojaRuta: function() { | 339 | getNumeroHojaRuta: function() { |
| 320 | return { | 340 | return { |
| 321 | then: function() { } | 341 | then: function() { } |
| 322 | }; | 342 | }; |
| 343 | }, | ||
| 344 | getParametros: function () { | ||
| 345 | return { | ||
| 346 | then: function() { } | ||
| 347 | }; | ||
| 323 | } | 348 | } |
| 324 | }, | 349 | }, |
| 325 | focaModalService: focaModalService, | 350 | focaModalService: focaModalService, |
| 326 | focaBotoneraLateralService: {}, | 351 | focaBotoneraLateralService: {}, |
| 327 | focaLoginService: {}, | 352 | focaLoginService: {}, |
| 328 | $localStorage: function() {} | 353 | $localStorage: function() {} |
| 329 | }); | 354 | }); |
| 330 | scope.hojaRuta = { | 355 | scope.hojaRuta = { |
| 331 | chofer: { id: true }, | 356 | chofer: { id: true }, |
| 332 | vehiculo: { id: true }, | 357 | vehiculo: { id: true }, |
| 333 | transportista: { }, | 358 | transportista: { }, |
| 334 | remitosTabla: [1] | 359 | remitosTabla: [1] |
| 335 | }; | 360 | }; |
| 336 | 361 | ||
| 337 | //act | 362 | //act |
| 338 | spyOn(focaModalService, 'alert'); | 363 | spyOn(focaModalService, 'alert'); |
| 339 | 364 | ||
| 340 | scope.crearHojaRuta(); | 365 | scope.crearHojaRuta(); |
| 341 | 366 | ||
| 342 | //assert | 367 | //assert |
| 343 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Transportista'); | 368 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Transportista'); |
| 344 | }); | 369 | }); |
| 345 | 370 | ||
| 346 | it('guardar hoja ruta valida que tenga tarifario', function() { | 371 | it('guardar hoja ruta valida que tenga tarifario', function() { |
| 347 | 372 | ||
| 348 | //arrange | 373 | //arrange |
| 349 | var scope = { | 374 | var scope = { |
| 350 | $broadcast: function() { }, | 375 | $broadcast: function() { }, |
| 351 | $watch: function() {} | 376 | $watch: function() {} |
| 352 | }; | 377 | }; |
| 353 | var focaModalService = { | 378 | var focaModalService = { |
| 354 | alert: function() { } | 379 | alert: function() { } |
| 355 | }; | 380 | }; |
| 356 | 381 | ||
| 357 | $controller('hojaRutaCtrl', { | 382 | $controller('hojaRutaCtrl', { |
| 358 | $scope: scope, | 383 | $scope: scope, |
| 359 | $uibModal: {}, | 384 | $uibModal: {}, |
| 360 | $location: {}, | 385 | $location: {}, |
| 361 | $filter: $filter, | 386 | $filter: $filter, |
| 362 | $timeout: $timeout, | 387 | $timeout: $timeout, |
| 363 | focaCrearHojaRutaService: { | 388 | focaCrearHojaRutaService: { |
| 364 | getBotonera: function() { }, | 389 | getBotonera: function() { }, |
| 365 | getNumeroHojaRuta: function() { | 390 | getNumeroHojaRuta: function() { |
| 366 | return { | 391 | return { |
| 367 | then: function() { } | 392 | then: function() { } |
| 368 | }; | 393 | }; |
| 394 | }, | ||
| 395 | getParametros: function () { | ||
| 396 | return { | ||
| 397 | then: function() { } | ||
| 398 | }; | ||
| 369 | } | 399 | } |
| 370 | }, | 400 | }, |
| 371 | focaModalService: focaModalService, | 401 | focaModalService: focaModalService, |
| 372 | focaBotoneraLateralService: {}, | 402 | focaBotoneraLateralService: {}, |
| 373 | focaLoginService: {}, | 403 | focaLoginService: {}, |
| 374 | $localStorage: function() {} | 404 | $localStorage: function() {} |
| 375 | }); | 405 | }); |
| 376 | scope.hojaRuta = { | 406 | scope.hojaRuta = { |
| 377 | chofer: { id: true }, | 407 | chofer: { id: true }, |
| 378 | vehiculo: { id: true }, | 408 | vehiculo: { id: true }, |
| 379 | transportista: { COD: true }, | 409 | transportista: { COD: true }, |
| 380 | tarifario: { }, | ||
| 381 | remitosTabla: [1] | 410 | remitosTabla: [1] |
| 382 | }; | 411 | }; |
| 383 | 412 | ||
| 384 | //act | 413 | //act |
| 385 | spyOn(focaModalService, 'alert'); | 414 | spyOn(focaModalService, 'alert'); |
| 386 | 415 | ||
| 387 | scope.crearHojaRuta(); | 416 | scope.crearHojaRuta(); |
| 388 | 417 | ||
| 389 | //assert | 418 | //assert |
| 390 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Tarifario'); | 419 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Tarifario'); |
| 391 | }); | 420 | }); |
| 392 | 421 | ||
| 393 | it('guardar hoja ruta valida que tenga datosExtra', function() { | 422 | it('guardar hoja ruta valida que tenga datosExtra', function() { |
| 394 | 423 | ||
| 395 | //arrange | 424 | //arrange |
| 396 | var scope = { | 425 | var scope = { |
| 397 | $broadcast: function() { }, | 426 | $broadcast: function() { }, |
| 398 | $watch: function() {} | 427 | $watch: function() {} |
| 399 | }; | 428 | }; |
| 400 | var focaModalService = { | 429 | var focaModalService = { |
| 401 | alert: function() { } | 430 | alert: function() { } |
| 402 | }; | 431 | }; |
| 403 | 432 | ||
| 404 | $controller('hojaRutaCtrl', { | 433 | $controller('hojaRutaCtrl', { |
| 405 | $scope: scope, | 434 | $scope: scope, |
| 406 | $uibModal: {}, | 435 | $uibModal: {}, |
| 407 | $location: {}, | 436 | $location: {}, |
| 408 | $filter: $filter, | 437 | $filter: $filter, |
| 409 | $timeout: $timeout, | 438 | $timeout: $timeout, |
| 410 | focaCrearHojaRutaService: { | 439 | focaCrearHojaRutaService: { |
| 411 | getBotonera: function() { }, | 440 | getBotonera: function() { }, |
| 412 | getNumeroHojaRuta: function() { | 441 | getNumeroHojaRuta: function() { |
| 413 | return { | 442 | return { |
| 414 | then: function() { } | 443 | then: function() { } |
| 415 | }; | 444 | }; |
| 445 | }, | ||
| 446 | getParametros: function () { | ||
| 447 | return { | ||
| 448 | then: function() { } | ||
| 449 | }; | ||
| 416 | } | 450 | } |
| 417 | }, | 451 | }, |
| 418 | focaModalService: focaModalService, | 452 | focaModalService: focaModalService, |
| 419 | focaBotoneraLateralService: {}, | 453 | focaBotoneraLateralService: {}, |
| 420 | focaLoginService: {}, | 454 | focaLoginService: {}, |
| 421 | $localStorage: function() {} | 455 | $localStorage: function() {} |
| 422 | }); | 456 | }); |
| 423 | scope.hojaRuta = { | 457 | scope.hojaRuta = { |
| 424 | chofer: { id: true }, | 458 | chofer: { id: true }, |
| 425 | vehiculo: { id: true }, | 459 | vehiculo: { id: true }, |
| 426 | transportista: { COD: true }, | 460 | transportista: { COD: true }, |
| 427 | tarifario: { costo: true }, | 461 | tarifario: { costo: true }, |
| 428 | remitosTabla: [1] | 462 | remitosTabla: [1] |
| 429 | }; | 463 | }; |
| 430 | 464 | ||
| 431 | //act | 465 | //act |
| 432 | spyOn(focaModalService, 'alert'); | 466 | spyOn(focaModalService, 'alert'); |
| 433 | 467 | ||
| 434 | scope.crearHojaRuta(); | 468 | scope.crearHojaRuta(); |
| 435 | 469 | ||
| 436 | //assert | 470 | //assert |
| 437 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Datos extra'); | 471 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Datos extra'); |
| 438 | }); | 472 | }); |
| 439 | 473 | ||
| 440 | it('guardar hoja ruta llama focaCrearHojaRutaService.crearHojaRuta', function() { | 474 | it('guardar hoja ruta llama focaCrearHojaRutaService.crearHojaRuta', function() { |
| 441 | 475 | ||
| 442 | //arrange | 476 | //arrange |
| 443 | var scope = { | 477 | var scope = { |
| 444 | $broadcast: function() { }, | 478 | $broadcast: function() { }, |
| 445 | $watch: function() {} | 479 | $watch: function() {} |
| 446 | }; | 480 | }; |
| 447 | var focaCrearHojaRutaService = { | 481 | var focaCrearHojaRutaService = { |
| 448 | getBotonera: function() { }, | 482 | getBotonera: function() { }, |
| 449 | getNumeroHojaRuta: function() { | 483 | getNumeroHojaRuta: function() { |
| 450 | return { | 484 | return { |
| 451 | then: function() { } | 485 | then: function() { } |
| 452 | }; | 486 | }; |
| 453 | }, | 487 | }, |
| 454 | crearHojaRuta: function() { } | 488 | crearHojaRuta: function() { }, |
| 489 | getParametros: function () { | ||
| 490 | return { | ||
| 491 | then: function() { } | ||
| 492 | }; | ||
| 493 | } | ||
| 455 | }; | 494 | }; |
| 456 | 495 | ||
| 457 | $controller('hojaRutaCtrl', { | 496 | $controller('hojaRutaCtrl', { |
| 458 | $scope: scope, | 497 | $scope: scope, |
| 459 | $uibModal: {}, | 498 | $uibModal: {}, |
| 460 | $location: {}, | 499 | $location: {}, |
| 461 | $filter: $filter, | 500 | $filter: $filter, |
| 462 | $timeout: $timeout, | 501 | $timeout: $timeout, |
| 463 | focaCrearHojaRutaService: focaCrearHojaRutaService, | 502 | focaCrearHojaRutaService: focaCrearHojaRutaService, |
| 464 | focaModalService: {}, | 503 | focaModalService: {}, |
| 465 | focaBotoneraLateralService: {}, | 504 | focaBotoneraLateralService: {}, |
| 466 | focaLoginService: {}, | 505 | focaLoginService: {}, |
| 467 | $localStorage: function() {} | 506 | $localStorage: function() {} |
| 468 | }); | 507 | }); |
| 469 | scope.hojaRuta = { | 508 | scope.hojaRuta = { |
| 470 | chofer: { id: true }, | 509 | chofer: { id: true }, |
| 471 | vehiculo: { id: true }, | 510 | vehiculo: { id: true }, |
| 472 | transportista: { COD: true }, | 511 | transportista: { COD: true }, |
| 473 | tarifario: { costo: true }, | 512 | tarifario: { costo: true }, |
| 474 | datosExtra: { }, | 513 | datosExtra: { }, |
| 475 | fechaReparto: new Date(), | 514 | fechaReparto: new Date(), |
| 476 | remitosTabla: [1] | 515 | remitosTabla: [1] |
| 477 | }; | 516 | }; |
| 478 | 517 | ||
| 479 | var respuesta = { then: function() { } }; | 518 | var respuesta = { then: function() { } }; |
| 480 | 519 | ||
| 481 | //act | 520 | //act |
| 482 | spyOn(focaCrearHojaRutaService, 'crearHojaRuta').and.returnValue(respuesta); | 521 | spyOn(focaCrearHojaRutaService, 'crearHojaRuta').and.returnValue(respuesta); |
| 483 | 522 | ||
| 484 | scope.crearHojaRuta(); | 523 | scope.crearHojaRuta(); |
| 485 | 524 | ||
| 486 | //assert | 525 | //assert |
| 487 | expect(focaCrearHojaRutaService.crearHojaRuta).toHaveBeenCalled(); | 526 | expect(focaCrearHojaRutaService.crearHojaRuta).toHaveBeenCalled(); |
| 488 | }); | 527 | }); |
| 489 | 528 | ||
| 490 | it('seleccionarTransportista levanta modal y setea datos', function(done) { | 529 | it('seleccionarTransportista levanta modal y setea datos', function(done) { |
| 491 | 530 | ||
| 492 | //arrange | 531 | //arrange |
| 493 | var scope = { | 532 | var scope = { |
| 494 | $broadcast: function() { }, | 533 | $broadcast: function() { }, |
| 495 | $watch: function() {} | 534 | $watch: function() {} |
| 496 | }; | 535 | }; |
| 497 | var focaModalService = { | 536 | var focaModalService = { |
| 498 | modal: function() { } | 537 | modal: function() { } |
| 499 | }; | 538 | }; |
| 500 | 539 | ||
| 501 | $controller('hojaRutaCtrl', { | 540 | $controller('hojaRutaCtrl', { |
| 502 | $scope: scope, | 541 | $scope: scope, |
| 503 | $uibModal: {}, | 542 | $uibModal: {}, |
| 504 | $location: {}, | 543 | $location: {}, |
| 505 | $filter: $filter, | 544 | $filter: $filter, |
| 506 | $timeout: $timeout, | 545 | $timeout: $timeout, |
| 507 | focaCrearHojaRutaService: { | 546 | focaCrearHojaRutaService: { |
| 508 | getBotonera: function() { }, | 547 | getBotonera: function() { }, |
| 509 | getNumeroHojaRuta: function() { | 548 | getNumeroHojaRuta: function() { |
| 510 | return { | 549 | return { |
| 511 | then: function() { } | 550 | then: function() { } |
| 512 | }; | 551 | }; |
| 552 | }, | ||
| 553 | getParametros: function () { | ||
| 554 | return { | ||
| 555 | then: function() { } | ||
| 556 | }; | ||
| 513 | } | 557 | } |
| 514 | }, | 558 | }, |
| 515 | focaModalService: focaModalService, | 559 | focaModalService: focaModalService, |
| 516 | focaBotoneraLateralService: {}, | 560 | focaBotoneraLateralService: {}, |
| 517 | focaLoginService: {}, | 561 | focaLoginService: {}, |
| 518 | $localStorage: function() {} | 562 | $localStorage: function() {} |
| 519 | }); | 563 | }); |
| 520 | 564 | ||
| 521 | var respuesta = 1; | 565 | var respuesta = 1; |
| 522 | var promesa = Promise.resolve(respuesta); | 566 | var promesa = Promise.resolve(respuesta); |
| 523 | 567 | ||
| 524 | //act | 568 | //act |
| 525 | spyOn(focaModalService, 'modal').and.returnValue(promesa); | 569 | spyOn(focaModalService, 'modal').and.returnValue(promesa); |
| 526 | spyOn(scope, '$broadcast'); | 570 | spyOn(scope, '$broadcast'); |
| 527 | 571 | ||
| 528 | scope.seleccionarTransportista(); | 572 | scope.seleccionarTransportista(); |
| 529 | 573 | ||
| 530 | //assert | 574 | //assert |
| 531 | promesa.then(function() { | 575 | promesa.then(function() { |
| 532 | expect(focaModalService.modal).toHaveBeenCalled(); | 576 | expect(focaModalService.modal).toHaveBeenCalled(); |
| 533 | expect(scope.$broadcast).toHaveBeenCalled(); | 577 | expect(scope.$broadcast).toHaveBeenCalled(); |
| 534 | expect(scope.hojaRuta.transportista).toEqual(respuesta); | 578 | expect(scope.hojaRuta.transportista).toEqual(respuesta); |
| 535 | done(); | 579 | done(); |
| 536 | }); | 580 | }); |
| 537 | 581 | ||
| 538 | }); | 582 | }); |
| 539 | 583 | ||
| 540 | it('seleccionarChofer levanta modal y setea datos', function(done) { | 584 | it('seleccionarChofer levanta modal y setea datos', function(done) { |
| 541 | 585 | ||
| 542 | //arrange | 586 | //arrange |
| 543 | var scope = { | 587 | var scope = { |
| 544 | $broadcast: function() { }, | 588 | $broadcast: function() { }, |
| 545 | $watch: function() {} | 589 | $watch: function() {} |
| 546 | }; | 590 | }; |
| 547 | var focaModalService = { | 591 | var focaModalService = { |
| 548 | modal: function() { } | 592 | modal: function() { } |
| 549 | }; | 593 | }; |
| 550 | 594 | ||
| 551 | $controller('hojaRutaCtrl', { | 595 | $controller('hojaRutaCtrl', { |
| 552 | $scope: scope, | 596 | $scope: scope, |
| 553 | $uibModal: {}, | 597 | $uibModal: {}, |
| 554 | $location: {}, | 598 | $location: {}, |
| 555 | $filter: $filter, | 599 | $filter: $filter, |
| 556 | $timeout: $timeout, | 600 | $timeout: $timeout, |
| 557 | focaCrearHojaRutaService: { | 601 | focaCrearHojaRutaService: { |
| 558 | getBotonera: function() { }, | 602 | getBotonera: function() { }, |
| 559 | getNumeroHojaRuta: function() { | 603 | getNumeroHojaRuta: function() { |
| 560 | return { | 604 | return { |
| 561 | then: function() { } | 605 | then: function() { } |
| 562 | }; | 606 | }; |
| 607 | }, | ||
| 608 | getParametros: function () { | ||
| 609 | return { | ||
| 610 | then: function() { } | ||
| 611 | }; | ||
| 563 | } | 612 | } |
| 564 | }, | 613 | }, |
| 565 | focaModalService: focaModalService, | 614 | focaModalService: focaModalService, |
| 566 | focaBotoneraLateralService: {}, | 615 | focaBotoneraLateralService: {}, |
| 567 | focaLoginService: {}, | 616 | focaLoginService: {}, |
| 568 | $localStorage: function() {} | 617 | $localStorage: function() {} |
| 569 | }); | 618 | }); |
| 570 | 619 | ||
| 571 | var respuesta = 1; | 620 | var respuesta = 1; |
| 572 | var promesa = Promise.resolve(respuesta); | 621 | var promesa = Promise.resolve(respuesta); |
| 573 | 622 | ||
| 574 | //act | 623 | //act |
| 575 | spyOn(focaModalService, 'modal').and.returnValue(promesa); | 624 | spyOn(focaModalService, 'modal').and.returnValue(promesa); |
| 576 | spyOn(scope, '$broadcast'); | 625 | spyOn(scope, '$broadcast'); |
| 577 | 626 | ||
| 578 | scope.seleccionarChofer(); | 627 | scope.seleccionarChofer(); |
| 579 | 628 | ||
| 580 | //assert | 629 | //assert |
| 581 | promesa.then(function() { | 630 | promesa.then(function() { |
| 582 | expect(focaModalService.modal).toHaveBeenCalled(); | 631 | expect(focaModalService.modal).toHaveBeenCalled(); |
| 583 | expect(scope.$broadcast).toHaveBeenCalled(); | 632 | expect(scope.$broadcast).toHaveBeenCalled(); |
| 584 | expect(scope.hojaRuta.chofer).toEqual(respuesta); | 633 | expect(scope.hojaRuta.chofer).toEqual(respuesta); |
| 585 | done(); | 634 | done(); |
| 586 | }); | 635 | }); |
| 587 | 636 | ||
| 588 | }); | 637 | }); |
| 589 | 638 | ||
| 590 | it('seleccionarTarifario levanta prompt', function(done) { | 639 | it('seleccionarTarifario levanta prompt', function(done) { |
| 591 | 640 | ||
| 592 | //arrange | 641 | //arrange |
| 593 | var scope = { | 642 | var scope = { |
| 594 | $broadcast: function() { }, | 643 | $broadcast: function() { }, |
| 595 | $watch: function() {} | 644 | $watch: function() {} |
| 596 | }; | 645 | }; |
| 597 | var focaModalService = { | 646 | var focaModalService = { |
| 598 | prompt: function() { } | 647 | prompt: function() { } |
| 599 | }; | 648 | }; |
| 600 | 649 | ||
| 601 | $controller('hojaRutaCtrl', { | 650 | $controller('hojaRutaCtrl', { |
| 602 | $scope: scope, | 651 | $scope: scope, |
| 603 | $uibModal: {}, | 652 | $uibModal: {}, |
| 604 | $location: {}, | 653 | $location: {}, |
| 605 | $filter: $filter, | 654 | $filter: $filter, |
| 606 | $timeout: $timeout, | 655 | $timeout: $timeout, |
| 607 | focaCrearHojaRutaService: { | 656 | focaCrearHojaRutaService: { |
| 608 | getBotonera: function() { }, | 657 | getBotonera: function() { }, |
| 609 | getNumeroHojaRuta: function() { | 658 | getNumeroHojaRuta: function() { |
| 610 | return { | 659 | return { |
| 611 | then: function() { } | 660 | then: function() { } |
| 612 | }; | 661 | }; |
| 662 | }, | ||
| 663 | getParametros: function () { | ||
| 664 | return { | ||
| 665 | then: function() { } | ||
| 666 | }; | ||
| 613 | } | 667 | } |
| 614 | }, | 668 | }, |
| 615 | focaModalService: focaModalService, | 669 | focaModalService: focaModalService, |
| 616 | focaBotoneraLateralService: {}, | 670 | focaBotoneraLateralService: {}, |
| 617 | focaLoginService: {}, | 671 | focaLoginService: {}, |
| 618 | $localStorage: function() {} | 672 | $localStorage: function() {} |
| 619 | }); | 673 | }); |
| 620 | 674 | ||
| 621 | var respuesta = 1; | 675 | var respuesta = 1; |
| 622 | var promesa = Promise.resolve(respuesta); | 676 | var promesa = Promise.resolve(respuesta); |
| 623 | 677 | ||
| 624 | //act | 678 | //act |
| 625 | spyOn(focaModalService, 'prompt').and.returnValue(promesa); | 679 | spyOn(focaModalService, 'prompt').and.returnValue(promesa); |
| 626 | spyOn(scope, '$broadcast'); | 680 | spyOn(scope, '$broadcast'); |
| 627 | 681 | ||
| 628 | scope.seleccionarTarifario(); | 682 | scope.seleccionarTarifario(); |
| 629 | 683 | ||
| 630 | //assert | 684 | //assert |
| 631 | promesa.then(function() { | 685 | promesa.then(function() { |
| 632 | expect(focaModalService.prompt).toHaveBeenCalled(); | 686 | expect(focaModalService.prompt).toHaveBeenCalled(); |
| 633 | expect(scope.$broadcast).toHaveBeenCalled(); | 687 | expect(scope.$broadcast).toHaveBeenCalled(); |
| 634 | expect(scope.hojaRuta.tarifario.costo).toEqual(respuesta); | 688 | expect(scope.hojaRuta.tarifario).toEqual(respuesta); |
| 635 | done(); | 689 | done(); |
| 636 | }); | 690 | }); |
| 637 | 691 | ||
| 638 | }); | 692 | }); |
| 639 | 693 | ||
| 640 | it('seleccionarRemitos levanta modal y setea datos', function(done) { | 694 | it('seleccionarRemitos levanta modal y setea datos', function(done) { |
| 641 | 695 | ||
| 642 | //arrange | 696 | //arrange |
| 643 | var scope = { | 697 | var scope = { |
| 644 | $broadcast: function() { }, | 698 | $broadcast: function() { }, |
| 645 | $watch: function() {} | 699 | $watch: function() {} |
| 646 | }; | 700 | }; |
| 647 | var uibModal = { | 701 | var uibModal = { |
| 648 | open: function() { } | 702 | open: function() { } |
| 649 | }; | 703 | }; |
| 650 | 704 | ||
| 651 | $controller('hojaRutaCtrl', { | 705 | $controller('hojaRutaCtrl', { |
| 652 | $scope: scope, | 706 | $scope: scope, |
| 653 | $uibModal: uibModal, | 707 | $uibModal: uibModal, |
| 654 | $location: {}, | 708 | $location: {}, |
| 655 | $filter: $filter, | 709 | $filter: $filter, |
| 656 | $timeout: $timeout, | 710 | $timeout: $timeout, |
| 657 | focaCrearHojaRutaService: { | 711 | focaCrearHojaRutaService: { |
| 658 | getBotonera: function() { }, | 712 | getBotonera: function() { }, |
| 659 | getNumeroHojaRuta: function() { | 713 | getNumeroHojaRuta: function() { |
| 660 | return { | 714 | return { |
| 661 | then: function() { } | 715 | then: function() { } |
| 662 | }; | 716 | }; |
| 717 | }, | ||
| 718 | getParametros: function () { | ||
| 719 | return { | ||
| 720 | then: function() { } | ||
| 721 | }; | ||
| 663 | } | 722 | } |
| 664 | }, | 723 | }, |
| 665 | focaModalService: { | 724 | focaModalService: { |
| 666 | alert: function() {} | 725 | alert: function() {} |
| 667 | }, | 726 | }, |
| 668 | focaBotoneraLateralService: {}, | 727 | focaBotoneraLateralService: {}, |
| 669 | focaLoginService: {}, | 728 | focaLoginService: {}, |
| 670 | $localStorage: function() {} | 729 | $localStorage: function() {} |
| 671 | }); | 730 | }); |
| 672 | scope.eligioPreConfirmado = false; | 731 | scope.eligioPreConfirmado = false; |
| 673 | scope.hojaRuta = { | 732 | scope.hojaRuta = { |
| 674 | vehiculo: { | 733 | vehiculo: { |
| 675 | id: true | 734 | id: true |
| 676 | }, | 735 | }, |
| 677 | fechaReparto: true | 736 | fechaReparto: true |
| 678 | }; | 737 | }; |
| 679 | 738 | ||
| 680 | var respuesta = 1; | 739 | var respuesta = 1; |
| 681 | var promesa = { result: Promise.resolve(respuesta) }; | 740 | var promesa = { result: Promise.resolve(respuesta) }; |
| 682 | 741 | ||
| 683 | //act | 742 | //act |
| 684 | spyOn(uibModal, 'open').and.returnValue(promesa); | 743 | spyOn(uibModal, 'open').and.returnValue(promesa); |
| 685 | 744 | ||
| 686 | scope.seleccionarRemitos(); | 745 | scope.seleccionarRemitos(); |
| 687 | 746 | ||
| 688 | //assert | 747 | //assert |
| 689 | promesa.result.then(function() { | 748 | promesa.result.then(function() { |
| 690 | expect(uibModal.open).toHaveBeenCalled(); | 749 | expect(uibModal.open).toHaveBeenCalled(); |
| 691 | done(); | 750 | done(); |
| 692 | }); | 751 | }); |
| 693 | 752 | ||
| 694 | }); | 753 | }); |
| 695 | 754 | ||
| 696 | it('seleccionarVehiculosPrecargados levanta modal y setea datos', function(done) { | 755 | it('seleccionarVehiculosPrecargados levanta modal y setea datos', function(done) { |
| 697 | 756 | ||
| 698 | //arrange | 757 | //arrange |
| 699 | var scope = { | 758 | var scope = { |
| 700 | $broadcast: function() { }, | 759 | $broadcast: function() { }, |
| 701 | $watch: function() {} | 760 | $watch: function() {} |
| 702 | }; | 761 | }; |
| 703 | var focaModalService = { | 762 | var focaModalService = { |
| 704 | modal: function() { }, | 763 | modal: function() { }, |
| 705 | alert: function() { } | 764 | alert: function() { } |
| 706 | }; | 765 | }; |
| 707 | var focaCrearHojaRutaService = { | 766 | var focaCrearHojaRutaService = { |
| 708 | getBotonera: function() { }, | 767 | getBotonera: function() { }, |
| 709 | getNumeroHojaRuta: function() { | 768 | getNumeroHojaRuta: function() { |
| 710 | return { | 769 | return { |
| 711 | then: function() { } | 770 | then: function() { } |
| 712 | }; | 771 | }; |
| 713 | }, | 772 | }, |
| 714 | getRemitosByIdVehiculo: function() { | 773 | getRemitosByIdVehiculo: function() { |
| 715 | return { | 774 | return { |
| 716 | then: function() { } | 775 | then: function() { } |
| 717 | }; | 776 | }; |
| 777 | }, | ||
| 778 | getParametros: function () { | ||
| 779 | return { | ||
| 780 | then: function() { } | ||
| 781 | }; | ||
| 718 | } | 782 | } |
| 719 | }; | 783 | }; |
| 720 | 784 | ||
| 721 | $controller('hojaRutaCtrl', { | 785 | $controller('hojaRutaCtrl', { |
| 722 | $scope: scope, | 786 | $scope: scope, |
| 723 | $uibModal: {}, | 787 | $uibModal: {}, |
| 724 | $location: {}, | 788 | $location: {}, |
| 725 | $filter: $filter, | 789 | $filter: $filter, |
| 726 | $timeout: $timeout, | 790 | $timeout: $timeout, |
| 727 | focaCrearHojaRutaService: focaCrearHojaRutaService, | 791 | focaCrearHojaRutaService: focaCrearHojaRutaService, |
| 728 | focaModalService: focaModalService, | 792 | focaModalService: focaModalService, |
| 729 | focaBotoneraLateralService: {}, | 793 | focaBotoneraLateralService: {}, |
| 730 | focaLoginService: {}, | 794 | focaLoginService: {}, |
| 731 | $localStorage: function() {} | 795 | $localStorage: function() {} |
| 732 | }); | 796 | }); |
| 733 | scope.eligioPreConfirmado = false; | 797 | scope.eligioPreConfirmado = false; |
| 734 | scope.hojaRuta = { | 798 | scope.hojaRuta = { |
| 735 | fechaReparto: new Date() | 799 | fechaReparto: new Date() |
| 736 | }; | 800 | }; |
| 737 | 801 | ||
| 738 | var respuesta = { transportista: { } }; | 802 | var respuesta = { transportista: { } }; |
| 739 | var promesa = Promise.resolve(respuesta); | 803 | var promesa = Promise.resolve(respuesta); |
| 740 | 804 | ||
| 741 | //act | 805 | //act |
| 742 | spyOn(focaModalService, 'modal') | 806 | spyOn(focaModalService, 'modal') |
| 743 | .and.returnValue(promesa); | 807 | .and.returnValue(promesa); |
| 744 | spyOn(focaCrearHojaRutaService, 'getRemitosByIdVehiculo') | 808 | spyOn(focaCrearHojaRutaService, 'getRemitosByIdVehiculo') |
| 745 | .and.returnValue( { then: function() { } } ); | 809 | .and.returnValue( { then: function() { } } ); |
| 746 | spyOn(scope, '$broadcast'); | 810 | spyOn(scope, '$broadcast'); |
| 747 | 811 | ||
| 748 | scope.seleccionarVehiculosPrecargados(); | 812 | scope.seleccionarVehiculosPrecargados(); |
| 749 | 813 | ||
| 750 | //assert | 814 | //assert |
| 751 | promesa.then(function() { | 815 | promesa.then(function() { |
| 752 | expect(focaModalService.modal).toHaveBeenCalled(); | 816 | expect(focaModalService.modal).toHaveBeenCalled(); |
| 753 | expect(focaCrearHojaRutaService.getRemitosByIdVehiculo).toHaveBeenCalled(); | 817 | expect(focaCrearHojaRutaService.getRemitosByIdVehiculo).toHaveBeenCalled(); |
| 754 | expect(scope.$broadcast).toHaveBeenCalled(); | 818 | expect(scope.$broadcast).toHaveBeenCalled(); |
| 755 | done(); | 819 | done(); |
| 756 | }); | 820 | }); |
| 757 | 821 | ||
| 758 | }); | 822 | }); |
| 759 | 823 | ||
| 760 | it('cargarCisterna levanta modal y devuelve promesa', function(done) { | 824 | it('cargarCisterna levanta modal y devuelve promesa', function(done) { |
| 761 | 825 | ||
| 762 | //arrange | 826 | //arrange |
| 763 | var scope = { | 827 | var scope = { |
| 764 | $broadcast: function() { }, | 828 | $broadcast: function() { }, |
| 765 | $watch: function() {} | 829 | $watch: function() {} |
| 766 | }; | 830 | }; |
| 767 | var uibModal = { | 831 | var uibModal = { |
| 768 | open: function() { } | 832 | open: function() { } |
| 769 | }; | 833 | }; |
| 770 | 834 | ||
| 771 | $controller('hojaRutaCtrl', { | 835 | $controller('hojaRutaCtrl', { |
| 772 | $scope: scope, | 836 | $scope: scope, |
| 773 | $uibModal: uibModal, | 837 | $uibModal: uibModal, |
| 774 | $location: {}, | 838 | $location: {}, |
| 775 | $filter: $filter, | 839 | $filter: $filter, |
| 776 | $timeout: $timeout, | 840 | $timeout: $timeout, |
| 777 | focaCrearHojaRutaService: { | 841 | focaCrearHojaRutaService: { |
| 778 | getBotonera: function() { }, | 842 | getBotonera: function() { }, |
| 779 | getNumeroHojaRuta: function() { | 843 | getNumeroHojaRuta: function() { |
| 780 | return { | 844 | return { |
| 781 | then: function() { } | 845 | then: function() { } |
| 782 | }; | 846 | }; |
| 847 | }, | ||
| 848 | getParametros: function () { | ||
| 849 | return { | ||
| 850 | then: function() { } | ||
| 851 | }; | ||
| 783 | } | 852 | } |
| 784 | }, | 853 | }, |
| 785 | focaModalService: { | 854 | focaModalService: { |
| 786 | alert: function() {} | 855 | alert: function() {} |
| 787 | }, | 856 | }, |
| 788 | focaBotoneraLateralService: {}, | 857 | focaBotoneraLateralService: {}, |
| 789 | focaLoginService: {}, | 858 | focaLoginService: {}, |
| 790 | $localStorage: function() {} | 859 | $localStorage: function() {} |
| 791 | }); | 860 | }); |
| 792 | scope.eligioPreConfirmado = false; | 861 | scope.eligioPreConfirmado = false; |
| 793 | scope.hojaRuta = { | 862 | scope.hojaRuta = { |
| 794 | vehiculo: { | 863 | vehiculo: { |
| 795 | id: true | 864 | id: true |
| 796 | }, | 865 | }, |
| 797 | fechaReparto: true | 866 | fechaReparto: true |
| 798 | }; | 867 | }; |
| 799 | 868 | ||
| 800 | var respuesta = 1; | 869 | var respuesta = 1; |
| 801 | var promesa = { result: Promise.resolve(respuesta) }; | 870 | var promesa = { result: Promise.resolve(respuesta) }; |
| 802 | 871 | ||
| 803 | //act | 872 | //act |
| 804 | spyOn(uibModal, 'open').and.returnValue(promesa); | 873 | spyOn(uibModal, 'open').and.returnValue(promesa); |
| 805 | 874 | ||
| 806 | var resultado = scope.cargarCisterna(); | 875 | var resultado = scope.cargarCisterna(); |
| 807 | 876 | ||
| 808 | //assert | 877 | //assert |
| 809 | promesa.result.then(function() { | 878 | promesa.result.then(function() { |
| 810 | expect(uibModal.open).toHaveBeenCalled(); | 879 | expect(uibModal.open).toHaveBeenCalled(); |
| 811 | expect(typeof resultado).toEqual('object'); | 880 | expect(typeof resultado).toEqual('object'); |
| 812 | done(); | 881 | done(); |
| 813 | }); | 882 | }); |
| 814 | 883 | ||
| 815 | }); | 884 | }); |
| 816 | 885 | ||
| 817 | it('seleccionarFechaEntrega levanta modal', function(done) { | 886 | it('seleccionarFechaEntrega levanta modal', function(done) { |
| 818 | 887 | ||
| 819 | //arrange | 888 | //arrange |
| 820 | var scope = { | 889 | var scope = { |
| 821 | $broadcast: function() { }, | 890 | $broadcast: function() { }, |
| 822 | $watch: function() {} | 891 | $watch: function() {} |
| 823 | }; | 892 | }; |
| 824 | var focaModalService = { | 893 | var focaModalService = { |
| 825 | modalFecha: function() { } | 894 | modalFecha: function() { }, |
| 895 | confirm: function() { | ||
| 896 | return Promise.resolve({}); | ||
| 897 | } | ||
| 826 | }; | 898 | }; |
| 827 | 899 | ||
| 828 | $controller('hojaRutaCtrl', { | 900 | $controller('hojaRutaCtrl', { |
| 829 | $scope: scope, | 901 | $scope: scope, |
| 830 | $uibModal: {}, | 902 | $uibModal: {}, |
| 831 | $location: {}, | 903 | $location: {}, |
| 832 | $filter: $filter, | 904 | $filter: $filter, |
| 833 | $timeout: $timeout, | 905 | $timeout: $timeout, |
| 834 | focaCrearHojaRutaService: { | 906 | focaCrearHojaRutaService: { |
| 835 | getBotonera: function() { }, | 907 | getBotonera: function() { }, |
| 836 | getNumeroHojaRuta: function() { | 908 | getNumeroHojaRuta: function() { |
| 837 | return { | 909 | return { |
| 838 | then: function() { } | 910 | then: function() { } |
| 839 | }; | 911 | }; |
| 912 | }, | ||
| 913 | getParametros: function () { | ||
| 914 | return { | ||
| 915 | then: function() { } | ||
| 916 | }; | ||
| 840 | } | 917 | } |
| 841 | }, | 918 | }, |
| 842 | focaModalService: focaModalService, | 919 | focaModalService: focaModalService, |
| 843 | focaBotoneraLateralService: {}, | 920 | focaBotoneraLateralService: {}, |
| 844 | focaLoginService: {}, | 921 | focaLoginService: {}, |
| 845 | $localStorage: function() {} | 922 | $localStorage: function() {} |
| 846 | }); | 923 | }); |
| 847 | 924 | ||
| 848 | var respuesta = new Date(); | 925 | var respuesta = new Date(); |
| 849 | var promesa = Promise.resolve(respuesta); | 926 | var promesa = Promise.resolve(respuesta); |
| 850 | 927 | ||
| 851 | //act | 928 | //act |
| 852 | spyOn(focaModalService, 'modalFecha').and.returnValue(promesa); | 929 | spyOn(focaModalService, 'modalFecha').and.returnValue(promesa); |
| 853 | spyOn(scope, '$broadcast'); | 930 | spyOn(scope, '$broadcast'); |
| 854 | 931 | ||
| 855 | scope.seleccionarFechaEntrega(); | 932 | scope.seleccionarFechaEntrega(); |
| 856 | 933 | ||
| 857 | //assert | 934 | //assert |
| 858 | promesa.then(function() { | 935 | promesa.then(function() { |
| 859 | expect(focaModalService.modalFecha).toHaveBeenCalled(); | 936 | setTimeout(function() { |
| 860 | expect(scope.$broadcast).toHaveBeenCalled(); | 937 | |
| 861 | done(); | 938 | expect(focaModalService.modalFecha).toHaveBeenCalled(); |
| 939 | expect(scope.$broadcast).toHaveBeenCalled(); | ||
| 940 | done(); | ||
| 941 | }); | ||
| 862 | }); | 942 | }); |
| 863 | 943 | ||
| 864 | }); | 944 | }); |
| 865 | 945 | ||
| 866 | }); | 946 | }); |
| 867 | 947 | ||
| 868 | }); | 948 | }); |
src/js/controller.js
| 1 | angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', | 1 | angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
| 2 | [ | 2 | [ |
| 3 | '$scope', | 3 | '$scope', |
| 4 | '$uibModal', | 4 | '$uibModal', |
| 5 | '$location', | 5 | '$location', |
| 6 | '$filter', | 6 | '$filter', |
| 7 | '$timeout', | 7 | '$timeout', |
| 8 | 'focaCrearHojaRutaService', | 8 | 'focaCrearHojaRutaService', |
| 9 | 'focaModalService', | 9 | 'focaModalService', |
| 10 | 'focaBotoneraLateralService', | 10 | 'focaBotoneraLateralService', |
| 11 | 'focaLoginService', | 11 | 'focaLoginService', |
| 12 | '$localStorage', | 12 | '$localStorage', |
| 13 | function($scope, $uibModal, $location, $filter, $timeout, | 13 | function($scope, $uibModal, $location, $filter, $timeout, |
| 14 | focaCrearHojaRutaService, focaModalService, focaBotoneraLateralService, | 14 | focaCrearHojaRutaService, focaModalService, focaBotoneraLateralService, |
| 15 | focaLoginSrv, $localStorage) | 15 | focaLoginSrv, $localStorage) |
| 16 | { | 16 | { |
| 17 | config(); | 17 | config(); |
| 18 | 18 | ||
| 19 | function config() { | 19 | function config() { |
| 20 | $scope.botonera = focaCrearHojaRutaService.getBotonera(); | 20 | $scope.botonera = focaCrearHojaRutaService.getBotonera(); |
| 21 | $scope.datepickerAbierto = false; | 21 | $scope.datepickerAbierto = false; |
| 22 | $scope.show = false; | 22 | $scope.show = false; |
| 23 | $scope.cargando = true; | 23 | $scope.cargando = true; |
| 24 | $scope.now = new Date(); | 24 | $scope.now = new Date(); |
| 25 | $scope.puntoVenta = $filter('rellenarDigitos')(0, 4); | 25 | $scope.puntoVenta = $filter('rellenarDigitos')(0, 4); |
| 26 | $scope.comprobante = $filter('rellenarDigitos')(0, 8); | 26 | $scope.comprobante = $filter('rellenarDigitos')(0, 8); |
| 27 | 27 | ||
| 28 | //SETEO BOTONERA LATERAL | 28 | //SETEO BOTONERA LATERAL |
| 29 | $timeout(function() { | 29 | $timeout(function() { |
| 30 | focaBotoneraLateralService.showSalir(false); | 30 | focaBotoneraLateralService.showSalir(false); |
| 31 | focaBotoneraLateralService.showPausar(true); | 31 | focaBotoneraLateralService.showPausar(true); |
| 32 | focaBotoneraLateralService.showGuardar(true, $scope.crearHojaRuta); | 32 | focaBotoneraLateralService.showGuardar(true, $scope.crearHojaRuta); |
| 33 | focaBotoneraLateralService.addCustomButton('Salir', salir); | 33 | focaBotoneraLateralService.addCustomButton('Salir', salir); |
| 34 | }); | 34 | }); |
| 35 | 35 | ||
| 36 | focaCrearHojaRutaService.getParametros().then(function(res) { | ||
| 37 | |||
| 38 | var parametros = JSON.parse(res.data[0].jsonText); | ||
| 39 | |||
| 40 | if ($localStorage.hojaRuta) { | ||
| 41 | $timeout(function() {getLSHojaRuta();}); | ||
| 42 | } else { | ||
| 43 | |||
| 44 | for(var property in parametros) { | ||
| 45 | $scope.hojaRuta[property] = parametros[property]; | ||
| 46 | $scope.inicial[property] = parametros[property]; | ||
| 47 | } | ||
| 48 | |||
| 49 | setearHojaRuta($scope.hojaRuta); | ||
| 50 | } | ||
| 51 | }); | ||
| 36 | init(); | 52 | init(); |
| 37 | $timeout(function() {getLSHojaRuta();}); | ||
| 38 | } | 53 | } |
| 39 | 54 | ||
| 40 | function init() { | 55 | function init() { |
| 41 | $scope.$broadcast('cleanCabecera'); | 56 | $scope.$broadcast('cleanCabecera'); |
| 42 | 57 | ||
| 43 | $scope.hojaRuta = { | 58 | $scope.hojaRuta = { |
| 44 | fecha: new Date(), | 59 | fecha: new Date(), |
| 45 | litros: 0, | 60 | litros: 0, |
| 46 | chofer: {}, | 61 | chofer: {}, |
| 47 | vehiculo: { | 62 | vehiculo: { |
| 48 | capacidad: 0 | 63 | capacidad: 0 |
| 49 | }, | 64 | }, |
| 50 | transportista: {}, | 65 | transportista: {}, |
| 51 | tarifario: { | ||
| 52 | costo: null | ||
| 53 | }, | ||
| 54 | remitosTabla: [] | 66 | remitosTabla: [] |
| 55 | }; | 67 | }; |
| 56 | $scope.idLista = undefined; | 68 | $scope.idLista = undefined; |
| 57 | 69 | ||
| 58 | focaCrearHojaRutaService.getNumeroHojaRuta().then( | 70 | focaCrearHojaRutaService.getNumeroHojaRuta().then( |
| 59 | function(res) { | 71 | function(res) { |
| 60 | $scope.puntoVenta = $filter('rellenarDigitos')(res.data.sucursal, 4); | 72 | $scope.puntoVenta = $filter('rellenarDigitos')(res.data.sucursal, 4); |
| 61 | $scope.comprobante = $filter('rellenarDigitos')(res.data.numeroHojaRuta, 8); | 73 | $scope.comprobante = $filter('rellenarDigitos')(res.data.numeroHojaRuta, 8); |
| 62 | }, | 74 | }, |
| 63 | function(err) { | 75 | function(err) { |
| 64 | focaModalService.alert('La terminal no esta configurada correctamente'); | 76 | focaModalService.alert('La terminal no esta configurada correctamente'); |
| 65 | console.info(err); | 77 | console.info(err); |
| 66 | } | 78 | } |
| 67 | ); | 79 | ); |
| 68 | setearFecha(new Date()); | 80 | setearFecha(new Date()); |
| 69 | $scope.inicial = angular.copy($scope.hojaRuta); | 81 | $scope.inicial = angular.copy($scope.hojaRuta); |
| 70 | } | 82 | } |
| 71 | 83 | ||
| 72 | $scope.$watch('hojaRuta', function(newValue) { | 84 | $scope.$watch('hojaRuta', function(newValue) { |
| 85 | |||
| 86 | // Seteo checked en remitos | ||
| 87 | if ($scope.hojaRuta.remitosTabla.length) { | ||
| 88 | |||
| 89 | $filter('filter')($scope.botonera, { | ||
| 90 | label: 'Remitos', | ||
| 91 | })[0].checked = true; | ||
| 92 | } else { | ||
| 93 | $filter('filter')($scope.botonera, { | ||
| 94 | label: 'Remitos', | ||
| 95 | })[0].checked = false; | ||
| 96 | } | ||
| 97 | |||
| 73 | focaBotoneraLateralService.setPausarData({ | 98 | focaBotoneraLateralService.setPausarData({ |
| 74 | label: 'hojaRuta', | 99 | label: 'hojaRuta', |
| 75 | val: newValue | 100 | val: newValue |
| 76 | }); | 101 | }); |
| 77 | }, true); | 102 | }, true); |
| 78 | 103 | ||
| 79 | $scope.crearHojaRuta = function() { | 104 | $scope.crearHojaRuta = function() { |
| 80 | if (!$scope.hojaRuta.remitosTabla.length) { | 105 | if (!$scope.hojaRuta.remitosTabla.length) { |
| 81 | focaModalService.alert('Ingrese Remitos'); | 106 | focaModalService.alert('Ingrese Remitos'); |
| 82 | return; | 107 | return; |
| 83 | } | 108 | } |
| 84 | if (!$scope.hojaRuta.chofer.id) { | 109 | if (!$scope.hojaRuta.chofer.id) { |
| 85 | focaModalService.alert('Ingrese Chofer'); | 110 | focaModalService.alert('Ingrese Chofer'); |
| 86 | return; | 111 | return; |
| 87 | } | 112 | } |
| 88 | if (!$scope.hojaRuta.vehiculo.id) { | 113 | if (!$scope.hojaRuta.vehiculo.id) { |
| 89 | focaModalService.alert('Ingrese Vehiculo'); | 114 | focaModalService.alert('Ingrese Vehiculo'); |
| 90 | return; | 115 | return; |
| 91 | } | 116 | } |
| 92 | if (!$scope.hojaRuta.transportista.COD) { | 117 | if (!$scope.hojaRuta.transportista.COD) { |
| 93 | focaModalService.alert('Ingrese Transportista'); | 118 | focaModalService.alert('Ingrese Transportista'); |
| 94 | return; | 119 | return; |
| 95 | } | 120 | } |
| 96 | if (!$scope.hojaRuta.tarifario.costo) { | 121 | if (!$scope.hojaRuta.tarifario) { |
| 97 | focaModalService.alert('Ingrese Tarifario'); | 122 | focaModalService.alert('Ingrese Tarifario'); |
| 98 | return; | 123 | return; |
| 99 | } | 124 | } |
| 100 | if (!$scope.hojaRuta.datosExtra) { | 125 | if (!$scope.hojaRuta.datosExtra) { |
| 101 | focaModalService.alert('Ingrese Datos extra'); | 126 | focaModalService.alert('Ingrese Datos extra'); |
| 102 | return; | 127 | return; |
| 103 | } | 128 | } |
| 104 | var date = new Date(); | 129 | var date = new Date(); |
| 105 | var save = { | 130 | var save = { |
| 106 | hojaRuta: { | 131 | hojaRuta: { |
| 107 | id: 0, | 132 | id: 0, |
| 108 | fechaCreacion: new Date(date.getTime()).toISOString().slice(0, 19) | 133 | fechaCreacion: new Date(date.getTime()).toISOString().slice(0, 19) |
| 109 | .replace('T', ' '), | 134 | .replace('T', ' '), |
| 110 | idTransportista: $scope.hojaRuta.transportista.COD, | 135 | idTransportista: $scope.hojaRuta.transportista.COD, |
| 111 | idChofer: $scope.hojaRuta.chofer.id, | 136 | idChofer: $scope.hojaRuta.chofer.id, |
| 112 | idVehiculo: $scope.hojaRuta.vehiculo.id, | 137 | idVehiculo: $scope.hojaRuta.vehiculo.id, |
| 113 | tarifaFlete: $scope.hojaRuta.tarifario.costo, | 138 | tarifaFlete: $scope.hojaRuta.tarifario, |
| 114 | fechaReparto: | 139 | fechaReparto: |
| 115 | new Date($scope.hojaRuta.fechaReparto).toISOString().substring(0, 10), | 140 | new Date($scope.hojaRuta.fechaReparto).toISOString().substring(0, 10), |
| 116 | estado: 0 | 141 | estado: 0 |
| 117 | }, | 142 | }, |
| 118 | remitos: $scope.hojaRuta.remitosTabla | 143 | remitos: $scope.hojaRuta.remitosTabla |
| 119 | }; | 144 | }; |
| 120 | save.hojaRuta = angular.extend({}, save.hojaRuta, $scope.hojaRuta.datosExtra); | 145 | save.hojaRuta = angular.extend({}, save.hojaRuta, $scope.hojaRuta.datosExtra); |
| 121 | focaCrearHojaRutaService.crearHojaRuta(save).then( | 146 | focaCrearHojaRutaService.crearHojaRuta(save).then( |
| 122 | function(data) { | 147 | function(data) { |
| 123 | focaModalService.alert( | 148 | focaModalService.alert( |
| 124 | 'Hoja ruta creada Nº: ' + | 149 | 'Hoja ruta creada Nº: ' + |
| 125 | $filter('rellenarDigitos')(data.data.sucursal, 4) + '-' + | 150 | $filter('rellenarDigitos')(data.data.sucursal, 4) + '-' + |
| 126 | $filter('rellenarDigitos')(data.data.numeroHojaRuta, 8) | 151 | $filter('rellenarDigitos')(data.data.numeroHojaRuta, 8) |
| 127 | ); | 152 | ); |
| 128 | 153 | ||
| 129 | init(); | 154 | config(); |
| 130 | }, | 155 | }, |
| 131 | function(error) { | 156 | function(error) { |
| 132 | focaModalService.alert('Hubo un error al crear la hoja de ruta'); | 157 | focaModalService.alert('Hubo un error al crear la hoja de ruta'); |
| 133 | console.info(error); | 158 | console.info(error); |
| 134 | } | 159 | } |
| 135 | ); | 160 | ); |
| 136 | }; | 161 | }; |
| 137 | 162 | ||
| 138 | $scope.seleccionarTransportista = function() { | 163 | $scope.seleccionarTransportista = function() { |
| 139 | if (eligioPreConfirmado()) return; | 164 | if (eligioPreConfirmado()) return; |
| 140 | var parametrosModal = { | 165 | var parametrosModal = { |
| 141 | titulo: 'Búsqueda de transportista', | 166 | titulo: 'Búsqueda de transportista', |
| 142 | query: '/transportista', | 167 | query: '/transportista', |
| 143 | columnas: [ | 168 | columnas: [ |
| 144 | { | 169 | { |
| 145 | nombre: 'Código', | 170 | nombre: 'Código', |
| 146 | propiedad: 'COD' | 171 | propiedad: 'COD' |
| 147 | }, | 172 | }, |
| 148 | { | 173 | { |
| 149 | nombre: 'Nombre', | 174 | nombre: 'Nombre', |
| 150 | propiedad: 'NOM' | 175 | propiedad: 'NOM' |
| 151 | }, | 176 | }, |
| 152 | { | 177 | { |
| 153 | nombre: 'CUIT', | 178 | nombre: 'CUIT', |
| 154 | propiedad: 'CUIT' | 179 | propiedad: 'CUIT' |
| 155 | } | 180 | } |
| 156 | ] | 181 | ] |
| 157 | }; | 182 | }; |
| 158 | focaModalService.modal(parametrosModal).then( | 183 | focaModalService.modal(parametrosModal).then( |
| 159 | function(proveedor) { | 184 | function(proveedor) { |
| 160 | $scope.hojaRuta.transportista = proveedor; | 185 | $scope.hojaRuta.transportista = proveedor; |
| 161 | $scope.$broadcast('addCabecera', { | 186 | $scope.$broadcast('addCabecera', { |
| 162 | label: 'Transportista:', | 187 | label: 'Transportista:', |
| 163 | valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + | 188 | valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + |
| 164 | proveedor.NOM | 189 | proveedor.NOM |
| 165 | }); | 190 | }); |
| 191 | |||
| 192 | $filter('filter')($scope.botonera, { | ||
| 193 | label: 'Transportista', | ||
| 194 | })[0].checked = true; | ||
| 166 | }, function() { | 195 | }, function() { |
| 167 | 196 | ||
| 168 | } | 197 | } |
| 169 | ); | 198 | ); |
| 170 | }; | 199 | }; |
| 171 | 200 | ||
| 172 | $scope.seleccionarChofer = function() { | 201 | $scope.seleccionarChofer = function() { |
| 173 | var parametrosModal = { | 202 | var parametrosModal = { |
| 174 | titulo: 'Búsqueda de Chofer', | 203 | titulo: 'Búsqueda de Chofer', |
| 175 | query: '/chofer', | 204 | query: '/chofer', |
| 176 | columnas: [ | 205 | columnas: [ |
| 177 | { | 206 | { |
| 178 | propiedad: 'id', | 207 | propiedad: 'id', |
| 179 | nombre: 'Código', | 208 | nombre: 'Código', |
| 180 | filtro: { | 209 | filtro: { |
| 181 | nombre: 'rellenarDigitos', | 210 | nombre: 'rellenarDigitos', |
| 182 | parametro: 3 | 211 | parametro: 3 |
| 183 | } | 212 | } |
| 184 | }, | 213 | }, |
| 185 | { | 214 | { |
| 186 | propiedad: 'nombre', | 215 | propiedad: 'nombre', |
| 187 | nombre: 'Nombre' | 216 | nombre: 'Nombre' |
| 188 | }, | 217 | }, |
| 189 | { | 218 | { |
| 190 | propiedad: 'dni', | 219 | propiedad: 'dni', |
| 191 | nombre: 'DNI' | 220 | nombre: 'DNI' |
| 192 | }, | 221 | }, |
| 193 | { | 222 | { |
| 194 | propiedad: 'telefono', | 223 | propiedad: 'telefono', |
| 195 | nombre: 'Teléfono' | 224 | nombre: 'Teléfono' |
| 196 | } | 225 | } |
| 197 | ] | 226 | ] |
| 198 | }; | 227 | }; |
| 199 | focaModalService.modal(parametrosModal).then( | 228 | focaModalService.modal(parametrosModal).then( |
| 200 | function(chofer) { | 229 | function(chofer) { |
| 201 | $scope.hojaRuta.chofer = chofer; | 230 | $scope.hojaRuta.chofer = chofer; |
| 202 | $scope.$broadcast('addCabecera', { | 231 | $scope.$broadcast('addCabecera', { |
| 203 | label: 'Chofer:', | 232 | label: 'Chofer:', |
| 204 | valor: $filter('rellenarDigitos')(chofer.id, 3) + ' - ' +chofer.nombre | 233 | valor: $filter('rellenarDigitos')(chofer.id, 3) + ' - ' +chofer.nombre |
| 205 | }); | 234 | }); |
| 235 | |||
| 236 | $filter('filter')($scope.botonera, { | ||
| 237 | label: 'Chofer', | ||
| 238 | })[0].checked = true; | ||
| 206 | }, function() { | 239 | }, function() { |
| 207 | // funcion ejecutada cuando se cancela el modal | 240 | // funcion ejecutada cuando se cancela el modal |
| 208 | } | 241 | } |
| 209 | ); | 242 | ); |
| 210 | }; | 243 | }; |
| 211 | 244 | ||
| 212 | $scope.seleccionarVehiculo = function() { | 245 | $scope.seleccionarVehiculo = function() { |
| 213 | if (!eligioFecha() || eligioPreConfirmado()) return; | 246 | if (!eligioFecha() || eligioPreConfirmado()) return; |
| 214 | modalVehiculos(); | 247 | modalVehiculos(); |
| 215 | }; | 248 | }; |
| 216 | 249 | ||
| 217 | $scope.seleccionarTarifario = function() { | 250 | $scope.seleccionarTarifario = function() { |
| 218 | focaModalService | 251 | focaModalService |
| 219 | .prompt({ | 252 | .prompt({ |
| 220 | titulo: 'Tarifa flete', | 253 | titulo: 'Tarifa flete', |
| 221 | value: $scope.hojaRuta.tarifario.costo | 254 | value: $scope.hojaRuta.tarifario |
| 222 | }) | 255 | }) |
| 223 | .then(function(costo) { | 256 | .then(function(costo) { |
| 224 | if (isNaN(costo)) { | 257 | if (isNaN(costo)) { |
| 225 | focaModalService | 258 | focaModalService |
| 226 | .alert('Ingrese un valor válido') | 259 | .alert('Ingrese un valor válido') |
| 227 | .then(function() { | 260 | .then(function() { |
| 228 | $scope.seleccionarTarifario(); | 261 | $scope.seleccionarTarifario(); |
| 229 | }); | 262 | }); |
| 230 | 263 | ||
| 231 | return; | 264 | return; |
| 232 | } | 265 | } |
| 233 | 266 | ||
| 234 | $scope.hojaRuta.tarifario.costo = costo; | 267 | $scope.hojaRuta.tarifario = costo; |
| 235 | $scope.$broadcast('addCabecera', { | 268 | $scope.$broadcast('addCabecera', { |
| 236 | label: 'Tarifario:', | 269 | label: 'Tarifario:', |
| 237 | valor: costo | 270 | valor: costo |
| 238 | }); | 271 | }); |
| 272 | |||
| 273 | $filter('filter')($scope.botonera, { | ||
| 274 | label: 'Tarifario', | ||
| 275 | })[0].checked = true; | ||
| 239 | }); | 276 | }); |
| 240 | }; | 277 | }; |
| 241 | 278 | ||
| 242 | $scope.seleccionarRemitos = function() { | 279 | $scope.seleccionarRemitos = function() { |
| 243 | if (eligioPreConfirmado() || !eligioFecha() || !eligioVehiculo()) return; | 280 | if (eligioPreConfirmado() || !eligioFecha() || !eligioVehiculo()) return; |
| 244 | var modalInstance = $uibModal.open( | 281 | var modalInstance = $uibModal.open( |
| 245 | { | 282 | { |
| 246 | ariaLabelledBy: 'Busqueda de Remito', | 283 | ariaLabelledBy: 'Busqueda de Remito', |
| 247 | templateUrl: 'foca-modal-remito.html', | 284 | templateUrl: 'foca-modal-remito.html', |
| 248 | controller: 'focaModalRemitoController', | 285 | controller: 'focaModalRemitoController', |
| 249 | size: 'lg', | 286 | size: 'lg', |
| 250 | resolve: {usadoPor: function() {return 'hojaRuta';}} | 287 | resolve: {usadoPor: function() {return 'hojaRuta';}} |
| 251 | } | 288 | } |
| 252 | ); | 289 | ); |
| 253 | modalInstance.result.then( | 290 | modalInstance.result.then( |
| 254 | function(remito) { | 291 | function(remito) { |
| 255 | // TODO: borrar cuando no se use definitivamente | 292 | // TODO: borrar cuando no se use definitivamente |
| 256 | // for (var i = $scope.hojaRuta.remitosTabla.length - 1; i >= 0; i--) { | 293 | // for (var i = $scope.hojaRuta.remitosTabla.length - 1; i >= 0; i--) { |
| 257 | // if ($scope.hojaRuta.remitosTabla[i].id === remito.id) { | 294 | // if ($scope.hojaRuta.remitosTabla[i].id === remito.id) { |
| 258 | // focaModalService.alert('Remito ya incluido'); | 295 | // focaModalService.alert('Remito ya incluido'); |
| 259 | // return; | 296 | // return; |
| 260 | // } | 297 | // } |
| 261 | // } | 298 | // } |
| 262 | 299 | ||
| 263 | // var litros = 0; | 300 | // var litros = 0; |
| 264 | // for (var j = remito.articulosRemito.length - 1; j >= 0; j--) { | 301 | // for (var j = remito.articulosRemito.length - 1; j >= 0; j--) { |
| 265 | // litros = litros + parseFloat(remito.articulosRemito[j].cantidad); | 302 | // litros = litros + parseFloat(remito.articulosRemito[j].cantidad); |
| 266 | // } | 303 | // } |
| 267 | 304 | ||
| 268 | // if ($scope.hojaRuta.litros >= $scope.hojaRuta.vehiculo.capacidad) { | 305 | // if ($scope.hojaRuta.litros >= $scope.hojaRuta.vehiculo.capacidad) { |
| 269 | // focaModalService.alert( | 306 | // focaModalService.alert( |
| 270 | // 'Debe ingresar toda la información para el transporte' | 307 | // 'Debe ingresar toda la información para el transporte' |
| 271 | // ); | 308 | // ); |
| 272 | // return; | 309 | // return; |
| 273 | // } | 310 | // } |
| 274 | 311 | ||
| 275 | //if($scope.hojaRuta.litros + litros >= $scope.hojaRuta.vehiculo.capacidad) | 312 | //if($scope.hojaRuta.litros + litros >= $scope.hojaRuta.vehiculo.capacidad) |
| 276 | // { | 313 | // { |
| 277 | // var litrostotales = litros; | 314 | // var litrostotales = litros; |
| 278 | // litros = $scope.hojaRuta.vehiculo.capacidad - $scope.hojaRuta.litros; | 315 | // litros = $scope.hojaRuta.vehiculo.capacidad - $scope.hojaRuta.litros; |
| 279 | // focaModalService.alert( | 316 | // focaModalService.alert( |
| 280 | // 'La carga excede la capacidad disponible del vehiculo. ' + | 317 | // 'La carga excede la capacidad disponible del vehiculo. ' + |
| 281 | // 'Excedente no cargado: ' + (litrostotales - litros) + ' litros' | 318 | // 'Excedente no cargado: ' + (litrostotales - litros) + ' litros' |
| 282 | // ); | 319 | // ); |
| 283 | // } | 320 | // } |
| 284 | 321 | ||
| 285 | // remito.litros = litros; | 322 | // remito.litros = litros; |
| 286 | // $scope.hojaRuta.litros = $scope.hojaRuta.litros + litros; | 323 | // $scope.hojaRuta.litros = $scope.hojaRuta.litros + litros; |
| 287 | $scope.cargarCisterna(remito.id).then(function() { | 324 | $scope.cargarCisterna(remito.id).then(function() { |
| 288 | $scope.hojaRuta.remitosTabla.push(remito); | 325 | $scope.hojaRuta.remitosTabla.push(remito); |
| 289 | }, function(error) { | 326 | }, function(error) { |
| 290 | 327 | ||
| 291 | if (error && error !== 'backdrop click') { | 328 | if (error && error !== 'backdrop click') { |
| 292 | 329 | ||
| 293 | focaModalService | 330 | focaModalService |
| 294 | .alert(error || 'Ha ocurrido un error') | 331 | .alert(error || 'Ha ocurrido un error') |
| 295 | .then(function() { | 332 | .then(function() { |
| 296 | $scope.seleccionarRemitos(); | 333 | $scope.seleccionarRemitos(); |
| 297 | }); | 334 | }); |
| 298 | 335 | ||
| 299 | } else { | 336 | } else { |
| 300 | 337 | ||
| 301 | $scope.seleccionarRemitos(); | 338 | $scope.seleccionarRemitos(); |
| 302 | 339 | ||
| 303 | } | 340 | } |
| 304 | }); | 341 | }); |
| 305 | }, function() { | 342 | }, function() { |
| 306 | // funcion ejecutada cuando se cancela el modal | 343 | // funcion ejecutada cuando se cancela el modal |
| 307 | } | 344 | } |
| 308 | ); | 345 | ); |
| 309 | }; | 346 | }; |
| 310 | 347 | ||
| 311 | $scope.seleccionarVehiculosPrecargados = function() { | 348 | $scope.seleccionarVehiculosPrecargados = function() { |
| 312 | if (!eligioFecha()) return; | 349 | if (!eligioFecha()) return; |
| 313 | modalVehiculos(true); | 350 | modalVehiculos(true); |
| 314 | }; | 351 | }; |
| 315 | 352 | ||
| 316 | $scope.cargarCisterna = function(idRemito) { | 353 | $scope.cargarCisterna = function(idRemito) { |
| 317 | if (!eligioFecha() || !$scope.hojaRuta.vehiculo.id) return; | 354 | if (!eligioFecha() || !$scope.hojaRuta.vehiculo.id) return; |
| 318 | var modalInstance = $uibModal.open( | 355 | var modalInstance = $uibModal.open( |
| 319 | { | 356 | { |
| 320 | ariaLabelledBy: 'Busqueda de Vehiculo', | 357 | ariaLabelledBy: 'Busqueda de Vehiculo', |
| 321 | templateUrl: 'foca-detalle-vehiculo.html', | 358 | templateUrl: 'foca-detalle-vehiculo.html', |
| 322 | controller: 'focaDetalleVehiculo', | 359 | controller: 'focaDetalleVehiculo', |
| 323 | size: 'lg', | 360 | size: 'lg', |
| 324 | resolve: { | 361 | resolve: { |
| 325 | idVehiculo: function() {return $scope.hojaRuta.vehiculo.id;}, | 362 | idVehiculo: function() {return $scope.hojaRuta.vehiculo.id;}, |
| 326 | idRemito: function() {return idRemito;}, | 363 | idRemito: function() {return idRemito;}, |
| 327 | fechaReparto: function() {return $scope.hojaRuta.fechaReparto;} | 364 | fechaReparto: function() {return $scope.hojaRuta.fechaReparto;} |
| 328 | } | 365 | } |
| 329 | } | 366 | } |
| 330 | ); | 367 | ); |
| 331 | return modalInstance.result; | 368 | return modalInstance.result; |
| 332 | }; | 369 | }; |
| 333 | 370 | ||
| 334 | $scope.seleccionarFechaEntrega = function() { | 371 | $scope.seleccionarFechaEntrega = function() { |
| 335 | var confirmacion = false; | 372 | var confirmacion = false; |
| 336 | var hasVehiculoId = $scope.hojaRuta.vehiculo.id !== undefined; | 373 | var hasVehiculoId = $scope.hojaRuta.vehiculo.id !== undefined; |
| 337 | var hasTarifario = $scope.hojaRuta.tarifario.costo !== null; | 374 | var hasTarifario = $scope.hojaRuta.tarifario !== null; |
| 338 | var hasTransportista = Object.keys($scope.hojaRuta.transportista).length > 0; | 375 | var hasTransportista = Object.keys($scope.hojaRuta.transportista).length > 0; |
| 339 | var hasChofer = Object.keys($scope.hojaRuta.chofer).length > 0; | 376 | var hasChofer = Object.keys($scope.hojaRuta.chofer).length > 0; |
| 340 | var hasDatosExtra = $scope.hojaRuta.datosExtra !== undefined; | 377 | var hasDatosExtra = $scope.hojaRuta.datosExtra !== undefined; |
| 341 | 378 | ||
| 342 | if (hasVehiculoId || hasTarifario || hasTransportista || | 379 | if (hasVehiculoId || hasTarifario || hasTransportista || |
| 343 | hasChofer || hasDatosExtra) { | 380 | hasChofer || hasDatosExtra) { |
| 344 | confirmacion = true; | 381 | confirmacion = true; |
| 345 | if (confirmacion) { | 382 | if (confirmacion) { |
| 346 | focaModalService | 383 | focaModalService |
| 347 | .confirm('Si cambia la fecha se perderán los datos actuales') | 384 | .confirm('Si cambia la fecha se perderán los datos actuales') |
| 348 | .then(function(data) { | 385 | .then(function(data) { |
| 349 | if(data) { | 386 | if(data) { |
| 350 | $scope.hojaRuta.vehiculo.id = undefined; | 387 | $scope.hojaRuta.vehiculo.id = undefined; |
| 351 | $scope.hojaRuta.tarifario.costo = null; | 388 | $scope.hojaRuta.tarifario = null; |
| 352 | $scope.hojaRuta.transportista = {}; | 389 | $scope.hojaRuta.transportista = {}; |
| 353 | $scope.hojaRuta.chofer = {}; | 390 | $scope.hojaRuta.chofer = {}; |
| 354 | $scope.hojaRuta.datosExtra = undefined; | 391 | $scope.hojaRuta.datosExtra = undefined; |
| 355 | elegirFecha(); | 392 | elegirFecha(); |
| 356 | } | 393 | } |
| 357 | }, function() { | 394 | }, function() { |
| 358 | return ; | 395 | return ; |
| 359 | }); | 396 | }); |
| 360 | } | 397 | } |
| 361 | } else { | 398 | } else { |
| 362 | elegirFecha(); | 399 | elegirFecha(); |
| 363 | } | 400 | } |
| 364 | } | 401 | }; |
| 365 | 402 | ||
| 366 | function setearFecha(fecha) { | 403 | function setearFecha(fecha) { |
| 367 | $timeout(function() { | 404 | $timeout(function() { |
| 368 | $scope.$broadcast('addCabecera', { | 405 | $scope.$broadcast('addCabecera', { |
| 369 | label: 'Fecha de entrega: ', | 406 | label: 'Fecha de entrega: ', |
| 370 | valor: fecha.toLocaleDateString() | 407 | valor: fecha.toLocaleDateString() |
| 371 | }); | 408 | }); |
| 372 | $scope.hojaRuta.fechaReparto = fecha; | 409 | $scope.hojaRuta.fechaReparto = fecha; |
| 410 | $scope.inicial.fechaReparto = fecha; | ||
| 373 | }); | 411 | }); |
| 374 | } | 412 | } |
| 375 | 413 | ||
| 376 | $scope.seleccionarDatosExtra = function() { | 414 | $scope.seleccionarDatosExtra = function() { |
| 377 | var datosHojaRuta = $scope.hojaRuta.datosExtra; | 415 | var datosHojaRuta = $scope.hojaRuta.datosExtra; |
| 378 | var modalInstance = $uibModal.open( | 416 | var modalInstance = $uibModal.open( |
| 379 | { | 417 | { |
| 380 | templateUrl: 'foca-modal-datos-hoja-ruta.html', | 418 | templateUrl: 'foca-modal-datos-hoja-ruta.html', |
| 381 | controller: 'focaModalDatosHojaRutaCtrl', | 419 | controller: 'focaModalDatosHojaRutaCtrl', |
| 382 | size: 'lg', | 420 | size: 'lg', |
| 383 | resolve: { | 421 | resolve: { |
| 384 | parametrosDatos: function() { | 422 | parametrosDatos: function() { |
| 385 | return { | 423 | return { |
| 386 | datosHojaRuta: datosHojaRuta | 424 | datosHojaRuta: datosHojaRuta |
| 387 | }; | 425 | }; |
| 388 | } | 426 | } |
| 389 | } | 427 | } |
| 390 | } | 428 | } |
| 391 | ); | 429 | ); |
| 392 | return modalInstance.result.then(function(datosExtra) { | 430 | return modalInstance.result.then(function(datosExtra) { |
| 431 | |||
| 432 | $filter('filter')($scope.botonera, { | ||
| 433 | label: 'Datos extra', | ||
| 434 | })[0].checked = true; | ||
| 435 | |||
| 393 | $scope.hojaRuta.datosExtra = datosExtra; | 436 | $scope.hojaRuta.datosExtra = datosExtra; |
| 394 | }, function() { | 437 | }, function() { |
| 395 | //se ejecuta cuando se cancela el modal | 438 | //se ejecuta cuando se cancela el modal |
| 396 | }); | 439 | }); |
| 397 | }; | 440 | }; |
| 398 | 441 | ||
| 399 | $scope.desasociarRemito = function(key, idRemito) { | 442 | $scope.desasociarRemito = function(key, idRemito) { |
| 400 | var idsRemito = [idRemito]; | 443 | var idsRemito = [idRemito]; |
| 401 | focaModalService.confirm('¿Está seguro que desea desasociar este remito del' + | 444 | focaModalService.confirm('¿Está seguro que desea desasociar este remito del' + |
| 402 | ' vehículo?').then(function() { | 445 | ' vehículo?').then(function() { |
| 403 | focaCrearHojaRutaService.desasociarRemitos(idsRemito, | 446 | focaCrearHojaRutaService.desasociarRemitos(idsRemito, |
| 404 | $scope.hojaRuta.vehiculo.id, $scope.hojaRuta.remitosTabla.length <= 1) | 447 | $scope.hojaRuta.vehiculo.id, $scope.hojaRuta.remitosTabla.length <= 1) |
| 405 | .then(function() { | 448 | .then(function() { |
| 406 | $scope.hojaRuta.remitosTabla.splice(key, 1); | 449 | $scope.hojaRuta.remitosTabla.splice(key, 1); |
| 407 | focaModalService.alert('Remito desasociado con éxito'); | 450 | focaModalService.alert('Remito desasociado con éxito'); |
| 408 | }); | 451 | }); |
| 409 | }); | 452 | }); |
| 410 | }; | 453 | }; |
| 411 | 454 | ||
| 412 | $scope.verProductosRemito = function(idRemito) { | 455 | $scope.verProductosRemito = function(idRemito) { |
| 413 | var parametrosModal = { | 456 | var parametrosModal = { |
| 414 | titulo: 'Articulos remito', | 457 | titulo: 'Articulos remito', |
| 415 | query: '/articulos/remito/' + idRemito, | 458 | query: '/articulos/remito/' + idRemito, |
| 416 | soloMostrar: true, | 459 | soloMostrar: true, |
| 417 | columnas: [ | 460 | columnas: [ |
| 418 | { | 461 | { |
| 419 | nombre: 'Código', | 462 | nombre: 'Código', |
| 420 | propiedad: 'codigo' | 463 | propiedad: 'codigo' |
| 421 | }, | 464 | }, |
| 422 | { | 465 | { |
| 423 | nombre: 'Descripción', | 466 | nombre: 'Descripción', |
| 424 | propiedad: 'descripcion' | 467 | propiedad: 'descripcion' |
| 425 | }, | 468 | }, |
| 426 | { | 469 | { |
| 427 | nombre: 'Cantidad', | 470 | nombre: 'Cantidad', |
| 428 | propiedad: 'cantidad' | 471 | propiedad: 'cantidad' |
| 429 | } | 472 | } |
| 430 | ] | 473 | ] |
| 431 | }; | 474 | }; |
| 432 | focaModalService.modal(parametrosModal).then(); | 475 | focaModalService.modal(parametrosModal).then(); |
| 433 | }; | 476 | }; |
| 434 | 477 | ||
| 435 | function elegirFecha() { | 478 | function elegirFecha() { |
| 436 | var fechaEntrega = { | 479 | var fechaEntrega = { |
| 437 | titulo: 'Fecha de entrega', | 480 | titulo: 'Fecha de entrega', |
| 438 | minDate: new Date() | 481 | minDate: new Date() |
| 439 | }; | 482 | }; |
| 440 | focaModalService.modalFecha(fechaEntrega).then(function(fecha) { | 483 | focaModalService.modalFecha(fechaEntrega).then(function(fecha) { |
| 484 | |||
| 485 | $scope.hojaRuta.fechaReparto = fecha; | ||
| 486 | |||
| 441 | $scope.$broadcast('addCabecera', { | 487 | $scope.$broadcast('addCabecera', { |
| 442 | label: 'Fecha de entrega: ', | 488 | label: 'Fecha de entrega: ', |
| 443 | valor: fecha.toLocaleDateString() | 489 | valor: fecha.toLocaleDateString() |
| 444 | }); | 490 | }); |
| 445 | $scope.hojaRuta.fechaReparto = fecha; | 491 | |
| 492 | $filter('filter')($scope.botonera, { | ||
| 493 | label: 'Fecha Entrega', | ||
| 494 | })[0].checked = true; | ||
| 446 | }); | 495 | }); |
| 447 | } | 496 | } |
| 448 | 497 | ||
| 449 | function eligioPreConfirmado() { | 498 | function eligioPreConfirmado() { |
| 450 | if ($scope.eligioPreConfirmado) { | 499 | if ($scope.eligioPreConfirmado) { |
| 451 | focaModalService.alert('No puede elegir si eligió un vehiculo pre cargado'); | 500 | focaModalService.alert('No puede elegir si eligió un vehiculo pre cargado'); |
| 452 | return true; | 501 | return true; |
| 453 | } | 502 | } |
| 454 | return false; | 503 | return false; |
| 455 | } | 504 | } |
| 456 | 505 | ||
| 457 | function eligioFecha() { | 506 | function eligioFecha() { |
| 458 | if (!$scope.hojaRuta.fechaReparto) { | 507 | if (!$scope.hojaRuta.fechaReparto) { |
| 459 | focaModalService.alert('Primero seleccione fecha de reparto'); | 508 | focaModalService.alert('Primero seleccione fecha de reparto'); |
| 460 | return false; | 509 | return false; |
| 461 | } | 510 | } |
| 462 | return true; | 511 | return true; |
| 463 | } | 512 | } |
| 464 | 513 | ||
| 465 | function eligioVehiculo() { | 514 | function eligioVehiculo() { |
| 466 | if (!$scope.hojaRuta.vehiculo.id) { | 515 | if (!$scope.hojaRuta.vehiculo.id) { |
| 467 | focaModalService.alert('Primero seleccione vehiculo'); | 516 | focaModalService.alert('Primero seleccione vehiculo'); |
| 468 | return false; | 517 | return false; |
| 469 | } | 518 | } |
| 470 | return true; | 519 | return true; |
| 471 | } | 520 | } |
| 472 | 521 | ||
| 473 | function modalVehiculos(preCargados) { | 522 | function modalVehiculos(preCargados) { |
| 474 | var parametrosModal = {}; | 523 | var parametrosModal = {}; |
| 475 | if (preCargados) { | 524 | if (preCargados) { |
| 476 | parametrosModal.query = '/vehiculo/obtener/pre-confirmados/' + | 525 | parametrosModal.query = '/vehiculo/obtener/pre-confirmados/' + |
| 477 | new Date($scope.hojaRuta.fechaReparto).toISOString().substring(0, 10); | 526 | new Date($scope.hojaRuta.fechaReparto).toISOString().substring(0, 10); |
| 478 | parametrosModal.titulo = 'Búsqueda de vehiculos pre confirmados'; | 527 | parametrosModal.titulo = 'Búsqueda de vehiculos pre confirmados'; |
| 479 | } else { | 528 | } else { |
| 480 | parametrosModal.query = '/vehiculo'; | 529 | parametrosModal.query = '/vehiculo'; |
| 481 | parametrosModal.titulo = 'Búsqueda de vehículos'; | 530 | parametrosModal.titulo = 'Búsqueda de vehículos'; |
| 482 | } | 531 | } |
| 483 | parametrosModal.columnas = [ | 532 | parametrosModal.columnas = [ |
| 484 | { | 533 | { |
| 485 | propiedad: 'codigo', | 534 | propiedad: 'codigo', |
| 486 | nombre: 'Código' | 535 | nombre: 'Código' |
| 487 | }, | 536 | }, |
| 488 | { | 537 | { |
| 489 | propiedad: 'tractor', | 538 | propiedad: 'tractor', |
| 490 | nombre: 'tractor' | 539 | nombre: 'tractor' |
| 491 | }, | 540 | }, |
| 492 | { | 541 | { |
| 493 | propiedad: 'semi', | 542 | propiedad: 'semi', |
| 494 | nombre: 'Semi' | 543 | nombre: 'Semi' |
| 495 | } | 544 | } |
| 496 | ]; | 545 | ]; |
| 497 | focaModalService.modal(parametrosModal).then(function(vehiculo) { | 546 | focaModalService.modal(parametrosModal).then(function(vehiculo) { |
| 498 | if (!preCargados && vehiculoEnUso(vehiculo)) return; | 547 | if (!preCargados && vehiculoEnUso(vehiculo)) return; |
| 499 | $scope.hojaRuta.vehiculo = vehiculo; | 548 | $scope.hojaRuta.vehiculo = vehiculo; |
| 500 | $scope.hojaRuta.transportista = vehiculo.transportista; | 549 | $scope.hojaRuta.transportista = vehiculo.transportista; |
| 501 | if (preCargados) { | 550 | if (preCargados) { |
| 502 | $scope.eligioPreConfirmado = true; | 551 | $scope.eligioPreConfirmado = true; |
| 503 | $scope.hojaRuta.vehiculo = vehiculo; | 552 | $scope.hojaRuta.vehiculo = vehiculo; |
| 504 | $scope.$broadcast('addCabecera', { | 553 | $scope.$broadcast('addCabecera', { |
| 505 | label: 'Transportista:', | 554 | label: 'Transportista:', |
| 506 | valor: $filter('rellenarDigitos')(vehiculo.transportista.COD, 5) + | 555 | valor: $filter('rellenarDigitos')(vehiculo.transportista.COD, 5) + |
| 507 | ' - ' + vehiculo.transportista.NOM | 556 | ' - ' + vehiculo.transportista.NOM |
| 508 | }); | 557 | }); |
| 509 | focaCrearHojaRutaService | 558 | focaCrearHojaRutaService |
| 510 | .getRemitosByIdVehiculo(vehiculo.id, $scope.hojaRuta.fechaReparto) | 559 | .getRemitosByIdVehiculo(vehiculo.id, $scope.hojaRuta.fechaReparto) |
| 511 | .then(function(res) { | 560 | .then(function(res) { |
| 561 | |||
| 562 | $filter('filter')($scope.botonera, { | ||
| 563 | label: 'Vehiculos precargados', | ||
| 564 | })[0].checked = true; | ||
| 565 | |||
| 512 | $scope.hojaRuta.remitosTabla = res.data; | 566 | $scope.hojaRuta.remitosTabla = res.data; |
| 513 | }); | 567 | }); |
| 514 | } else { | 568 | } else { |
| 515 | focaCrearHojaRutaService | 569 | focaCrearHojaRutaService |
| 516 | .getRemitosByIdVehiculo(vehiculo.id, $scope.hojaRuta.fechaReparto, true) | 570 | .getRemitosByIdVehiculo(vehiculo.id, $scope.hojaRuta.fechaReparto, true) |
| 517 | .then(function(res) { | 571 | .then(function(res) { |
| 572 | |||
| 573 | $filter('filter')($scope.botonera, { | ||
| 574 | label: 'Vehiculo', | ||
| 575 | })[0].checked = true; | ||
| 576 | |||
| 518 | $scope.hojaRuta.remitosTabla = res.data; | 577 | $scope.hojaRuta.remitosTabla = res.data; |
| 519 | }); | 578 | }); |
| 520 | } | 579 | } |
| 521 | $scope.$broadcast('addCabecera', { | 580 | $scope.$broadcast('addCabecera', { |
| 522 | label: 'Tractor:', | 581 | label: 'Tractor:', |
| 523 | valor: vehiculo.tractor | 582 | valor: vehiculo.tractor |
| 524 | }); | 583 | }); |
| 525 | $scope.$broadcast('addCabecera', { | 584 | $scope.$broadcast('addCabecera', { |
| 526 | label: 'Semi:', | 585 | label: 'Semi:', |
| 527 | valor: vehiculo.semi | 586 | valor: vehiculo.semi |
| 528 | }); | 587 | }); |
| 529 | $scope.$broadcast('addCabecera', { | 588 | $scope.$broadcast('addCabecera', { |
| 530 | label: 'Capacidad:', | 589 | label: 'Capacidad:', |
| 531 | valor: vehiculo.capacidad | 590 | valor: vehiculo.capacidad |
| 532 | }); | 591 | }); |
| 592 | |||
| 533 | }); | 593 | }); |
| 534 | } | 594 | } |
| 535 | 595 | ||
| 536 | function vehiculoEnUso(vehiculo) { | 596 | function vehiculoEnUso(vehiculo) { |
| 537 | var idUsuario = focaLoginSrv.getLoginData().vendedorCobrador; | 597 | var idUsuario = focaLoginSrv.getLoginData().vendedorCobrador; |
| 538 | for (var i = 0; i < vehiculo.cisternas.length; i++) { | 598 | for (var i = 0; i < vehiculo.cisternas.length; i++) { |
| 539 | for (var j = 0; j < vehiculo.cisternas[i].cisternasCarga.length; j++) { | 599 | for (var j = 0; j < vehiculo.cisternas[i].cisternasCarga.length; j++) { |
| 540 | var cisternaCarga = vehiculo.cisternas[i].cisternasCarga[j]; | 600 | var cisternaCarga = vehiculo.cisternas[i].cisternasCarga[j]; |
| 541 | if (cisternaCarga.fechaReparto.substring(0, 10) === | 601 | if (cisternaCarga.fechaReparto.substring(0, 10) === |
| 542 | new Date($scope.hojaRuta.fechaReparto).toISOString().substring(0, 10) && | 602 | new Date($scope.hojaRuta.fechaReparto).toISOString().substring(0, 10) && |
| 543 | cisternaCarga.idUsuarioProceso && | 603 | cisternaCarga.idUsuarioProceso && |
| 544 | cisternaCarga.idUsuarioProceso !== idUsuario) | 604 | cisternaCarga.idUsuarioProceso !== idUsuario) |
| 545 | { | 605 | { |
| 546 | focaModalService.alert('El vehículo está siendo usado por otro' + | 606 | focaModalService.alert('El vehículo está siendo usado por otro' + |
| 547 | ' usuario'); | 607 | ' usuario'); |
| 548 | return true; | 608 | return true; |
| 549 | } | 609 | } |
| 550 | } | 610 | } |
| 551 | } | 611 | } |
| 552 | return false; | 612 | return false; |
| 553 | } | 613 | } |
| 554 | 614 | ||
| 555 | function salir() { | 615 | function salir() { |
| 556 | var confirmacion = false; | 616 | var confirmacion = false; |
| 557 | 617 | ||
| 558 | if (!angular.equals($scope.hojaRuta, $scope.inicial)) { | 618 | if (!angular.equals($scope.hojaRuta, $scope.inicial)) { |
| 559 | confirmacion = true; | 619 | confirmacion = true; |
| 560 | } | 620 | } |
| 561 | 621 | ||
| 562 | if (confirmacion) { | 622 | if (confirmacion) { |
| 563 | focaModalService.confirm( | 623 | focaModalService.confirm( |
| 564 | '¿Está seguro de que desea salir? Se perderán todos los datos cargados.' | 624 | '¿Está seguro de que desea salir? Se perderán todos los datos cargados.' |
| 565 | ).then(function(data) { | 625 | ).then(function(data) { |
| 566 | if (data) { | 626 | if (data) { |
| 567 | $location.path('/'); | 627 | $location.path('/'); |
| 568 | } | 628 | } |
| 569 | }); | 629 | }); |
| 570 | } else { | 630 | } else { |
| 571 | $location.path('/'); | 631 | $location.path('/'); |
| 572 | } | 632 | } |
| 573 | } | 633 | } |
| 574 | 634 | ||
| 575 | function setearHojaRuta(hojaRuta) { | 635 | function setearHojaRuta(hojaRuta) { |
| 576 | $scope.$broadcast('cleanCabecera'); | 636 | $scope.$broadcast('cleanCabecera'); |
| 577 | 637 | ||
| 578 | var cabeceras = []; | 638 | var cabeceras = []; |
| 579 | if (hojaRuta.fechaReparto) { | 639 | if (hojaRuta.fechaReparto) { |
| 580 | cabeceras.push({ | 640 | cabeceras.push({ |
| 581 | label: 'Fecha de entrega:', | 641 | label: 'Fecha de entrega:', |
| 582 | valor: $filter('date')(hojaRuta.fechaReparto, 'dd/MM/yyyy') | 642 | valor: $filter('date')(hojaRuta.fechaReparto, 'dd/MM/yyyy') |
| 583 | }); | 643 | }); |
| 644 | |||
| 645 | $filter('filter')( $scope.botonera, { | ||
| 646 | label: 'Fecha Entrega' | ||
| 647 | })[0].checked = true; | ||
| 584 | } | 648 | } |
| 585 | if (hojaRuta.transportista.COD) { | 649 | if (hojaRuta.transportista.COD) { |
| 586 | cabeceras.push({ | 650 | cabeceras.push({ |
| 587 | label: 'Transportista:', | 651 | label: 'Transportista:', |
| 588 | valor: $filter('rellenarDigitos')(hojaRuta.transportista.COD, 5) + ' - ' + | 652 | valor: $filter('rellenarDigitos')(hojaRuta.transportista.COD, 5) + ' - ' + |
| 589 | hojaRuta.transportista.NOM | 653 | hojaRuta.transportista.NOM |
| 590 | }); | 654 | }); |
| 655 | |||
| 656 | $filter('filter')( $scope.botonera, { | ||
| 657 | label: 'Transportista' | ||
| 658 | })[0].checked = true; | ||
| 591 | } | 659 | } |
| 592 | if (hojaRuta.chofer.id) { | 660 | if (hojaRuta.chofer.id) { |
| 593 | cabeceras.push({ | 661 | cabeceras.push({ |
| 594 | label: 'Chofer:', | 662 | label: 'Chofer:', |
| 595 | valor: $filter('rellenarDigitos')(hojaRuta.chofer.id, 3) + | 663 | valor: $filter('rellenarDigitos')(hojaRuta.chofer.id, 3) + |
| 596 | ' - ' + hojaRuta.chofer.nombre | 664 | ' - ' + hojaRuta.chofer.nombre |
| 597 | }); | 665 | }); |
| 666 | |||
| 667 | $filter('filter')( $scope.botonera, { | ||
| 668 | label: 'Chofer' | ||
| 669 | })[0].checked = true; | ||
| 598 | } | 670 | } |
| 599 | if (hojaRuta.vehiculo.id) { | 671 | if (hojaRuta.vehiculo.id) { |
| 600 | cabeceras.push({ | 672 | cabeceras.push({ |
| 601 | label: 'Tractor:', | 673 | label: 'Tractor:', |
| 602 | valor: hojaRuta.vehiculo.tractor | 674 | valor: hojaRuta.vehiculo.tractor |
| 603 | }); | 675 | }); |
| 604 | cabeceras.push({ | 676 | cabeceras.push({ |
| 605 | label: 'Semi:', | 677 | label: 'Semi:', |
| 606 | valor: hojaRuta.vehiculo.semi | 678 | valor: hojaRuta.vehiculo.semi |
| 607 | }); | 679 | }); |
| 608 | cabeceras.push({ | 680 | cabeceras.push({ |
| 609 | label: 'Capacidad:', | 681 | label: 'Capacidad:', |
| 610 | valor: hojaRuta.vehiculo.capacidad | 682 | valor: hojaRuta.vehiculo.capacidad |
| 611 | }); | 683 | }); |
| 684 | |||
| 685 | $filter('filter')( $scope.botonera, { | ||
| 686 | label: 'Vehiculo' | ||
| 687 | })[0].checked = true; | ||
| 612 | } | 688 | } |
| 613 | if (hojaRuta.tarifario.costo) { | 689 | if (hojaRuta.tarifario) { |
| 614 | cabeceras.push({ | 690 | cabeceras.push({ |
| 615 | label: 'Tarifario:', | 691 | label: 'Tarifario:', |
| 616 | valor: hojaRuta.tarifario.costo | 692 | valor: hojaRuta.tarifario |
| 617 | }); | 693 | }); |
| 694 | |||
| 695 | $filter('filter')( $scope.botonera, { | ||
| 696 | label: 'Tarifario' | ||
| 697 | })[0].checked = true; | ||
| 618 | } | 698 | } |
| 619 | 699 | ||
| 620 | addArrayCabecera(cabeceras); | 700 | addArrayCabecera(cabeceras); |
| 621 | $scope.hojaRuta = hojaRuta; | 701 | $scope.hojaRuta = hojaRuta; |
| 622 | } | 702 | } |
| 623 | 703 | ||
| 624 | function getLSHojaRuta() { | 704 | function getLSHojaRuta() { |
| 625 | var hojaRuta = JSON.parse($localStorage.hojaRuta || null); | 705 | var hojaRuta = JSON.parse($localStorage.hojaRuta || null); |
| 626 | if (hojaRuta) { | 706 | if (hojaRuta) { |
| 627 | setearHojaRuta(hojaRuta); | 707 | setearHojaRuta(hojaRuta); |
| 628 | delete $localStorage.hojaRuta; | 708 | delete $localStorage.hojaRuta; |
| 629 | } | 709 | } |
| 630 | } | 710 | } |
| 631 | function addArrayCabecera(array) { | 711 | function addArrayCabecera(array) { |
| 632 | for(var i = 0; i < array.length; i++) { | 712 | for(var i = 0; i < array.length; i++) { |
| 633 | $scope.$broadcast('addCabecera', { | 713 | $scope.$broadcast('addCabecera', { |
| 634 | label: array[i].label, | 714 | label: array[i].label, |
| 635 | valor: array[i].valor | 715 | valor: array[i].valor |
| 636 | }); | 716 | }); |
| 637 | } | 717 | } |
src/js/service.js
| 1 | angular.module('focaCrearHojaRuta') | 1 | angular.module('focaCrearHojaRuta') |
| 2 | .service('focaCrearHojaRutaService', ['$http', 'API_ENDPOINT', | 2 | .service('focaCrearHojaRutaService', ['$http', 'API_ENDPOINT', |
| 3 | function($http, API_ENDPOINT) { | 3 | function($http, API_ENDPOINT) { |
| 4 | var route = API_ENDPOINT.URL; | 4 | var route = API_ENDPOINT.URL; |
| 5 | return { | 5 | return { |
| 6 | crearHojaRuta: function(hojaRuta) { | 6 | crearHojaRuta: function(hojaRuta) { |
| 7 | return $http.post(route + '/hoja-ruta', hojaRuta); | 7 | return $http.post(route + '/hoja-ruta', hojaRuta); |
| 8 | }, | 8 | }, |
| 9 | obtenerHojaRuta: function() { | 9 | obtenerHojaRuta: function() { |
| 10 | return $http.get(route +'/hoja-ruta'); | 10 | return $http.get(route +'/hoja-ruta'); |
| 11 | }, | 11 | }, |
| 12 | setHojaRuta: function(hojaRuta) { | 12 | setHojaRuta: function(hojaRuta) { |
| 13 | this.hojaRuta = hojaRuta; | 13 | this.hojaRuta = hojaRuta; |
| 14 | }, | 14 | }, |
| 15 | clearHojaRuta: function() { | 15 | clearHojaRuta: function() { |
| 16 | this.hojaRuta = undefined; | 16 | this.hojaRuta = undefined; |
| 17 | }, | 17 | }, |
| 18 | getHojaRuta: function() { | 18 | getHojaRuta: function() { |
| 19 | return this.hojaRuta; | 19 | return this.hojaRuta; |
| 20 | }, | 20 | }, |
| 21 | getArticulosByIdHojaRuta: function(id) { | 21 | getArticulosByIdHojaRuta: function(id) { |
| 22 | return $http.get(route+'/articulos/hoja-ruta/'+id); | 22 | return $http.get(route+'/articulos/hoja-ruta/'+id); |
| 23 | }, | 23 | }, |
| 24 | crearArticulosParaHojaRuta: function(articuloHojaRuta) { | 24 | crearArticulosParaHojaRuta: function(articuloHojaRuta) { |
| 25 | return $http.post(route + '/articulos/hoja-ruta', | 25 | return $http.post(route + '/articulos/hoja-ruta', |
| 26 | {articuloHojaRuta: articuloHojaRuta}); | 26 | {articuloHojaRuta: articuloHojaRuta}); |
| 27 | }, | 27 | }, |
| 28 | getDomiciliosByIdHojaRuta: function(id) { | 28 | getDomiciliosByIdHojaRuta: function(id) { |
| 29 | return $http.get(route +'/hoja-ruta/' + id + '/domicilios'); | 29 | return $http.get(route +'/hoja-ruta/' + id + '/domicilios'); |
| 30 | }, | 30 | }, |
| 31 | getDomiciliosByIdCliente: function(id) { | 31 | getDomiciliosByIdCliente: function(id) { |
| 32 | var idTipoEntrega = 2;//Solo traigo los domicilios que tienen tipo 2 (tipo entrega) | 32 | var idTipoEntrega = 2;//Solo traigo los domicilios que tienen tipo 2 (tipo entrega) |
| 33 | return $http.get(route + '/domicilio/tipo/' + idTipoEntrega + '/cliente/' + id ); | 33 | return $http.get(route + '/domicilio/tipo/' + idTipoEntrega + '/cliente/' + id ); |
| 34 | }, | 34 | }, |
| 35 | getPrecioCondicion: function() { | 35 | getPrecioCondicion: function() { |
| 36 | return $http.get(route + '/precio-condicion'); | 36 | return $http.get(route + '/precio-condicion'); |
| 37 | }, | 37 | }, |
| 38 | getPrecioCondicionById: function(id) { | 38 | getPrecioCondicionById: function(id) { |
| 39 | return $http.get(route + '/precio-condicion/' + id); | 39 | return $http.get(route + '/precio-condicion/' + id); |
| 40 | }, | 40 | }, |
| 41 | getPlazoPagoByPrecioCondicion: function(id) { | 41 | getPlazoPagoByPrecioCondicion: function(id) { |
| 42 | return $http.get(route + '/plazo-pago/precio-condicion/' + id); | 42 | return $http.get(route + '/plazo-pago/precio-condicion/' + id); |
| 43 | }, | 43 | }, |
| 44 | crearFlete: function(flete) { | 44 | crearFlete: function(flete) { |
| 45 | return $http.post(route + '/flete', {flete : flete}); | 45 | return $http.post(route + '/flete', {flete : flete}); |
| 46 | }, | 46 | }, |
| 47 | crearPlazosParaHojaRuta: function(plazos) { | 47 | crearPlazosParaHojaRuta: function(plazos) { |
| 48 | return $http.post(route + '/plazo-pago/hoja-ruta', plazos); | 48 | return $http.post(route + '/plazo-pago/hoja-ruta', plazos); |
| 49 | }, | 49 | }, |
| 50 | getCotizacionByIdMoneda: function(id) { | 50 | getCotizacionByIdMoneda: function(id) { |
| 51 | return $http.get(route + '/moneda/' + id); | 51 | return $http.get(route + '/moneda/' + id); |
| 52 | }, | 52 | }, |
| 53 | crearEstadoParaHojaRuta: function(estado) { | 53 | crearEstadoParaHojaRuta: function(estado) { |
| 54 | return $http.post(route + '/estado', {estado: estado}); | 54 | return $http.post(route + '/estado', {estado: estado}); |
| 55 | }, | 55 | }, |
| 56 | getNumeroHojaRuta: function() { | 56 | getNumeroHojaRuta: function() { |
| 57 | return $http.get(route + '/hoja-ruta/numero-siguiente'); | 57 | return $http.get(route + '/hoja-ruta/numero-siguiente'); |
| 58 | }, | 58 | }, |
| 59 | getRemitosByIdVehiculo: function(idVehiculo, fechaReparto, sinConfirmar) { | 59 | getRemitosByIdVehiculo: function(idVehiculo, fechaReparto, sinConfirmar) { |
| 60 | var noCofirmados = sinConfirmar ? '/sinConfirmar' : ''; | 60 | var noCofirmados = sinConfirmar ? '/sinConfirmar' : ''; |
| 61 | return $http.get(route + '/vehiculo/obtener/remitos/' + | 61 | return $http.get(route + '/vehiculo/obtener/remitos/' + |
| 62 | idVehiculo + '/' + fechaReparto.toISOString().substring(0, 10) + noCofirmados); | 62 | idVehiculo + '/' + fechaReparto.toISOString().substring(0, 10) + noCofirmados); |
| 63 | }, | 63 | }, |
| 64 | desasociarRemitos: function(idsRemitos, idVehiculo, sinRemitos) { | 64 | desasociarRemitos: function(idsRemitos, idVehiculo, sinRemitos) { |
| 65 | return $http.post(route + '/vehiculo/desasociar-remitos', | 65 | return $http.post(route + '/vehiculo/desasociar-remitos', |
| 66 | { | 66 | { |
| 67 | idsRemitos: idsRemitos, | 67 | idsRemitos: idsRemitos, |
| 68 | idVehiculo: idVehiculo, | 68 | idVehiculo: idVehiculo, |
| 69 | vehiculoSinRemitos: sinRemitos | 69 | vehiculoSinRemitos: sinRemitos |
| 70 | }); | 70 | }); |
| 71 | }, | 71 | }, |
| 72 | getParametros: function() { | ||
| 73 | return $http.get(API_ENDPOINT.URL + '/parametros/hojaRuta'); | ||
| 74 | }, | ||
| 72 | getBotonera: function() { | 75 | getBotonera: function() { |
| 73 | return [ | 76 | return [ |
| 74 | { | 77 | { |
| 75 | label: 'Fecha Entrega', | 78 | label: 'Fecha Entrega', |
| 76 | image: 'fechaDeReparto.png' | 79 | image: 'fechaDeReparto.png' |
| 77 | }, | 80 | }, |
| 78 | { | 81 | { |
| 79 | label: 'Transportista', | 82 | label: 'Transportista', |
| 80 | image: 'transportista.png' | 83 | image: 'transportista.png' |
| 81 | }, | 84 | }, |
| 82 | { | 85 | { |
| 83 | label: 'Chofer', | 86 | label: 'Chofer', |
| 84 | image: 'chofer.png' | 87 | image: 'chofer.png' |
| 85 | }, | 88 | }, |
| 86 | { | 89 | { |
| 87 | label: 'Vehiculo', | 90 | label: 'Vehiculo', |
| 88 | image: 'vehiculos.png' | 91 | image: 'vehiculos.png' |
| 89 | }, | 92 | }, |
| 90 | { | 93 | { |
| 91 | label: 'Tarifario', | 94 | label: 'Tarifario', |
| 92 | image: 'tarifario.png' | 95 | image: 'tarifario.png' |
| 93 | }, | 96 | }, |
| 94 | { | 97 | { |
| 95 | label: 'Remitos', | 98 | label: 'Remitos', |
| 96 | image: 'remito.png' | 99 | image: 'remito.png' |
| 97 | }, | 100 | }, |
| 98 | { | 101 | { |
| 99 | label: 'Vehiculos precargados', | 102 | label: 'Vehiculos precargados', |
| 100 | image: 'vehiculos.png' | 103 | image: 'vehiculos.png' |
| 101 | }, | 104 | }, |
| 102 | { | 105 | { |
| 103 | label: 'Datos extra', | 106 | label: 'Datos extra', |
| 104 | image: 'tarifario.png' | 107 | image: 'tarifario.png' |
| 105 | } | 108 | } |
| 106 | ]; | 109 | ]; |
| 107 | } | 110 | } |
| 108 | }; | 111 | }; |
| 109 | }]); | 112 | }]); |
| 110 | 113 |