Commit e5bbab58fefdbf88fe52141a7e613f2a3c37d961
1 parent
d3306bd983
Exists in
master
cc o contado
Showing
2 changed files
with
64 additions
and
63 deletions
Show diff stats
src/js/controller.js
| ... | ... | @@ -242,75 +242,77 @@ angular.module('focaCrearFactura').controller('facturaController', [ |
| 242 | 242 | |
| 243 | 243 | $scope.seleccionarCliente = function () { |
| 244 | 244 | |
| 245 | - var modalInstance = $uibModal.open( | |
| 246 | - { | |
| 247 | - ariaLabelledBy: 'Busqueda de Cliente', | |
| 248 | - templateUrl: 'foca-busqueda-cliente-modal.html', | |
| 249 | - controller: 'focaBusquedaClienteModalController', | |
| 250 | - resolve: { | |
| 251 | - parametros: function () { | |
| 252 | - return { | |
| 253 | - vendedor: function () { return null; }, | |
| 254 | - cobrador: function () { return null; } | |
| 255 | - }; | |
| 256 | - } | |
| 257 | - }, | |
| 258 | - size: 'lg' | |
| 259 | - } | |
| 260 | - ); | |
| 261 | - modalInstance.result.then( | |
| 262 | - function (cliente) { | |
| 263 | - crearFacturaService.getResumenCuenta(cliente.COD) | |
| 264 | - .then(function (res) { | |
| 265 | - $scope.estadoCuenta = res.data[0]; | |
| 266 | - if ($scope.estadoCuenta.autorizado > 0) { | |
| 267 | - var modalInstance = $uibModal.open( | |
| 268 | - { | |
| 269 | - templateUrl: 'modal-estado-cuenta.html', | |
| 270 | - controller: 'focaModalEstadoCuentaController', | |
| 271 | - size: 'lg', | |
| 272 | - resolve: { | |
| 273 | - parametros: function () { | |
| 274 | - return { | |
| 275 | - idCliente: cliente.COD, | |
| 276 | - nombreCliente: cliente.NOM | |
| 277 | - }; | |
| 278 | - }, | |
| 279 | - } | |
| 280 | - } | |
| 281 | - ) | |
| 282 | - }; | |
| 283 | - }) | |
| 284 | - .catch(function (err) { console.error(err); }) | |
| 245 | + var modalCliente = $uibModal.open({ | |
| 246 | + ariaLabelledBy: 'Busqueda de Cliente', | |
| 247 | + templateUrl: 'foca-busqueda-cliente-modal.html', | |
| 248 | + controller: 'focaBusquedaClienteModalController', | |
| 249 | + resolve: { | |
| 250 | + parametros: function () { | |
| 251 | + return { | |
| 252 | + vendedor: function () { return null; }, | |
| 253 | + cobrador: function () { return null; } | |
| 254 | + }; | |
| 255 | + } | |
| 256 | + }, | |
| 257 | + size: 'lg' | |
| 258 | + }); | |
| 259 | + modalCliente.result | |
| 260 | + .then(function (cliente) { | |
| 285 | 261 | |
| 286 | - modalInstance.result | |
| 287 | - .then(function (data) { | |
| 262 | + //#region SETEO DATA CLIENTE | |
| 263 | + $scope.factura.cliente = cliente; | |
| 288 | 264 | |
| 289 | - $scope.factura.formaPago = data.formaDePago; | |
| 290 | - $scope.factura.cliente = cliente; | |
| 265 | + getNumeroFactura(cliente.TIP); | |
| 291 | 266 | |
| 292 | - getNumeroFactura(cliente.TIP); | |
| 267 | + $scope.$broadcast('addCabecera', { | |
| 268 | + label: 'Cliente:', | |
| 269 | + valor: $filter('rellenarDigitos')(cliente.COD, 3) + | |
| 270 | + ' - ' + cliente.NOM | |
| 271 | + }); | |
| 293 | 272 | |
| 294 | - $scope.$broadcast('addCabecera', { | |
| 295 | - label: 'Cliente:', | |
| 296 | - valor: $filter('rellenarDigitos')(cliente.COD, 3) + | |
| 297 | - ' - ' + cliente.NOM | |
| 298 | - }); | |
| 273 | + $filter('filter')($scope.botonera, | |
| 274 | + { label: 'Cliente' })[0].checked = true; | |
| 275 | + //#endregion | |
| 299 | 276 | |
| 300 | - $filter('filter')($scope.botonera, | |
| 301 | - { label: 'Cliente' })[0].checked = true; | |
| 277 | + crearFacturaService.getResumenCuenta(cliente.COD) | |
| 278 | + .then(function (res) { | |
| 302 | 279 | |
| 303 | - $scope.$broadcast('addCabecera', { | |
| 304 | - label: 'Forma de pago: ', | |
| 305 | - valor: data.tipo | |
| 306 | - }); | |
| 280 | + $scope.estadoCuenta = res.data[0]; | |
| 281 | + if ($scope.estadoCuenta.autorizado > 0) { | |
| 282 | + var modalEstadoCuenta = $uibModal.open({ | |
| 283 | + templateUrl: 'modal-estado-cuenta.html', | |
| 284 | + controller: 'focaModalEstadoCuentaController', | |
| 285 | + size: 'lg', | |
| 286 | + resolve: { | |
| 287 | + parametros: function () { | |
| 288 | + return { | |
| 289 | + idCliente: cliente.COD, | |
| 290 | + nombreCliente: cliente.NOM | |
| 291 | + }; | |
| 292 | + }, | |
| 293 | + } | |
| 294 | + }); | |
| 295 | + modalEstadoCuenta.result | |
| 296 | + .then(function (data) { | |
| 297 | + $scope.factura.formaPago = data.formaDePago; | |
| 298 | + | |
| 299 | + $scope.$broadcast('addCabecera', { | |
| 300 | + label: 'Forma de pago: ', | |
| 301 | + valor: data.tipo | |
| 302 | + }); | |
| 303 | + }) | |
| 304 | + .catch($scope.seleccionarCliente); | |
| 305 | + } else { | |
| 306 | + $scope.factura.formaPago = 1; | |
| 307 | + $scope.$broadcast('addCabecera', { | |
| 308 | + label: 'Forma de pago: ', | |
| 309 | + valor: 'Contado' | |
| 310 | + }); | |
| 311 | + } | |
| 307 | 312 | }) |
| 308 | - .catch($scope.seleccionarCliente); | |
| 309 | - | |
| 310 | - }, function () { | |
| 311 | - } | |
| 312 | - ); | |
| 313 | - | |
| 313 | + .catch(function (err) { console.error(err); }) | |
| 314 | + }) | |
| 315 | + .catch(function (err) { console.error(err); }) | |
| 314 | 316 | }; |
| 315 | 317 | |
| 316 | 318 | $scope.seleccionarVendedor = function () { |