Commit 6c2eecd1c51b2d29792797b126591bf944e5948f

Authored by Benjamin Rodriguez
1 parent 7ce990808c
Exists in develop

bloqueo backdrop modal cliente

Showing 2 changed files with 3 additions and 1 deletions   Show diff stats
1 <html ng-app="focaCrearRemito"> 1 <html ng-app="focaCrearRemito">
2 <head> 2 <head>
3 <meta charset="UTF-8"/> 3 <meta charset="UTF-8"/>
4 <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> 4 <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
5 5
6 <!--CSS--> 6 <!--CSS-->
7 <link href="node_modules/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet"/> 7 <link href="node_modules/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet"/>
8 <link href="node_modules/font-awesome/css/font-awesome.min.css" rel="stylesheet"/> 8 <link href="node_modules/font-awesome/css/font-awesome.min.css" rel="stylesheet"/>
9 <link href="node_modules/ladda/dist/ladda-themeless.min.css" rel="stylesheet"> 9 <link href="node_modules/ladda/dist/ladda-themeless.min.css" rel="stylesheet">
10 10
11 <!--VENDOR JS--> 11 <!--VENDOR JS-->
12 <script src="node_modules/jquery/dist/jquery.min.js"></script> 12 <script src="node_modules/jquery/dist/jquery.min.js"></script>
13 <script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script> 13 <script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
14 <script src="node_modules/angular/angular.min.js"></script> 14 <script src="node_modules/angular/angular.min.js"></script>
15 <script src="node_modules/angular-route/angular-route.min.js"></script> 15 <script src="node_modules/angular-route/angular-route.min.js"></script>
16 <script src="node_modules/angular-cookies/angular-cookies.min.js"></script> 16 <script src="node_modules/angular-cookies/angular-cookies.min.js"></script>
17 <script src="node_modules/ui-bootstrap4/dist/ui-bootstrap-tpls.js"></script> 17 <script src="node_modules/ui-bootstrap4/dist/ui-bootstrap-tpls.js"></script>
18 <script src="node_modules/ladda/dist/spin.min.js"></script> 18 <script src="node_modules/ladda/dist/spin.min.js"></script>
19 <script src="node_modules/ladda/dist/ladda.min.js"></script> 19 <script src="node_modules/ladda/dist/ladda.min.js"></script>
20 <script src="node_modules/angular-ladda/dist/angular-ladda.min.js"></script> 20 <script src="node_modules/angular-ladda/dist/angular-ladda.min.js"></script>
21 <script src="vendor/cordovaGeolocationModule.min.js"></script> 21 <script src="vendor/cordovaGeolocationModule.min.js"></script>
22 22
23 <script src="node_modules/foca-directivas/dist/foca-directivas.min.js"></script> 23 <script src="node_modules/foca-directivas/dist/foca-directivas.min.js"></script>
24 <script src="node_modules/foca-modal-vendedores/dist/foca-modal-vendedores.min.js"></script> 24 <script src="node_modules/foca-modal-vendedores/dist/foca-modal-vendedores.min.js"></script>
25 <script src="node_modules/foca-modal-busqueda-productos/dist/foca-busqueda-productos.min.js"></script> 25 <script src="node_modules/foca-modal-busqueda-productos/dist/foca-busqueda-productos.min.js"></script>
26 <script src="node_modules/foca-modal-proveedor/dist/foca-modal-proveedor.min.js"></script> 26 <script src="node_modules/foca-modal-proveedor/dist/foca-modal-proveedor.min.js"></script>
27 <script src="node_modules/foca-busqueda-cliente/dist/foca-busqueda-cliente.min.js"></script> 27 <script src="node_modules/foca-busqueda-cliente/dist/foca-busqueda-cliente.min.js"></script>
28 <script src="node_modules/foca-modal-precio-condiciones/dist/foca-modal-precio-condiciones.min.js"></script> 28 <script src="node_modules/foca-modal-precio-condiciones/dist/foca-modal-precio-condiciones.min.js"></script>
29 <script src="node_modules/foca-modal-flete/dist/foca-modal-flete.min.js"></script> 29 <script src="node_modules/foca-modal-flete/dist/foca-modal-flete.min.js"></script>
30 <script src="node_modules/foca-modal/dist/foca-modal.min.js"></script> 30 <script src="node_modules/foca-modal/dist/foca-modal.min.js"></script>
31 <script src="node_modules/foca-modal-domicilio/dist/foca-modal-domicilios.min.js"></script> 31 <script src="node_modules/foca-modal-domicilio/dist/foca-modal-domicilio.min.js"></script>
32 <script src="./node_modules/foca-configuracion/dist/foca-configuracion.min.js"></script> 32 <script src="./node_modules/foca-configuracion/dist/foca-configuracion.min.js"></script>
33 <script src="node_modules/foca-modal-moneda/dist/foca-modal-moneda.min.js"></script> 33 <script src="node_modules/foca-modal-moneda/dist/foca-modal-moneda.min.js"></script>
34 <script src="node_modules/foca-modal-cotizacion/dist/foca-modal-cotizacion.min.js"></script> 34 <script src="node_modules/foca-modal-cotizacion/dist/foca-modal-cotizacion.min.js"></script>
35 <script src="node_modules/foca-seguimiento/dist/foca-seguimiento.min.js"></script> 35 <script src="node_modules/foca-seguimiento/dist/foca-seguimiento.min.js"></script>
36 <script src="node_modules/foca-modal-nota-pedido/dist/foca-modal-nota-pedido.min.js"></script> 36 <script src="node_modules/foca-modal-nota-pedido/dist/foca-modal-nota-pedido.min.js"></script>
37 <script src="node_modules/foca-botonera-facturador/dist/foca-botonera-facturador.min.js"></script> 37 <script src="node_modules/foca-botonera-facturador/dist/foca-botonera-facturador.min.js"></script>
38 38
39 <script src="src/js/app.js"></script> 39 <script src="src/js/app.js"></script>
40 <script src="src/js/controller.js"></script> 40 <script src="src/js/controller.js"></script>
41 <script src="src/js/service.js"></script> 41 <script src="src/js/service.js"></script>
42 <script src="src/js/businessService.js"></script> 42 <script src="src/js/businessService.js"></script>
43 <script src="src/js/route.js"></script> 43 <script src="src/js/route.js"></script>
44 44
45 <script src="src/etc/develop.js"></script> 45 <script src="src/etc/develop.js"></script>
46 </head> 46 </head>
47 <body> 47 <body>
48 <div ng-view class="container-fluid"></div> 48 <div ng-view class="container-fluid"></div>
49 </body> 49 </body>
50 </html> 50 </html>
51 51
src/js/controller.js
1 angular.module('focaCrearRemito').controller('remitoController', 1 angular.module('focaCrearRemito').controller('remitoController',
2 [ 2 [
3 '$scope', '$uibModal', '$location', '$filter', 'crearRemitoService', '$timeout', 3 '$scope', '$uibModal', '$location', '$filter', 'crearRemitoService', '$timeout',
4 'focaModalService', 'remitoBusinessService', '$rootScope', 'focaBotoneraLateralService', 4 'focaModalService', 'remitoBusinessService', '$rootScope', 'focaBotoneraLateralService',
5 '$localStorage', 5 '$localStorage',
6 function ( 6 function (
7 $scope, $uibModal, $location, $filter, crearRemitoService, $timeout, focaModalService, 7 $scope, $uibModal, $location, $filter, crearRemitoService, $timeout, focaModalService,
8 remitoBusinessService, $rootScope, focaBotoneraLateralService, $localStorage) { 8 remitoBusinessService, $rootScope, focaBotoneraLateralService, $localStorage) {
9 config(); 9 config();
10 10
11 var cotizacionPArgentino = {}; 11 var cotizacionPArgentino = {};
12 12
13 function config() { 13 function config() {
14 $scope.tmpCantidad = Number; 14 $scope.tmpCantidad = Number;
15 $scope.tmpPrecio = Number; 15 $scope.tmpPrecio = Number;
16 $scope.botonera = crearRemitoService.getBotonera(); 16 $scope.botonera = crearRemitoService.getBotonera();
17 $scope.isNumber = angular.isNumber; 17 $scope.isNumber = angular.isNumber;
18 $scope.datepickerAbierto = false; 18 $scope.datepickerAbierto = false;
19 $scope.show = false; 19 $scope.show = false;
20 $scope.cargando = true; 20 $scope.cargando = true;
21 $scope.now = new Date(); 21 $scope.now = new Date();
22 $scope.puntoVenta = rellenar(0, 4); 22 $scope.puntoVenta = rellenar(0, 4);
23 $scope.comprobante = rellenar(0, 8); 23 $scope.comprobante = rellenar(0, 8);
24 $scope.dateOptions = { 24 $scope.dateOptions = {
25 maxDate: new Date(), 25 maxDate: new Date(),
26 minDate: new Date(2010, 0, 1) 26 minDate: new Date(2010, 0, 1)
27 }; 27 };
28 $scope.cabeceras = []; 28 $scope.cabeceras = [];
29 crearRemitoService.getParametros().then(function (res) { 29 crearRemitoService.getParametros().then(function (res) {
30 var parametros = JSON.parse(res.data[0].jsonText); 30 var parametros = JSON.parse(res.data[0].jsonText);
31 if ($localStorage.remito) { 31 if ($localStorage.remito) {
32 $timeout(function () { getLSRemito(); }); 32 $timeout(function () { getLSRemito(); });
33 } else { 33 } else {
34 for (var property in parametros) { 34 for (var property in parametros) {
35 $scope.remito[property] = parametros[property]; 35 $scope.remito[property] = parametros[property];
36 $scope.inicial[property] = parametros[property]; 36 $scope.inicial[property] = parametros[property];
37 } 37 }
38 setearRemito($scope.remito); 38 setearRemito($scope.remito);
39 } 39 }
40 }); 40 });
41 41
42 //SETEO BOTONERA LATERAL 42 //SETEO BOTONERA LATERAL
43 $timeout(function () { 43 $timeout(function () {
44 focaBotoneraLateralService.showSalir(false); 44 focaBotoneraLateralService.showSalir(false);
45 focaBotoneraLateralService.showPausar(true); 45 focaBotoneraLateralService.showPausar(true);
46 focaBotoneraLateralService.showGuardar(true, $scope.crearRemito); 46 focaBotoneraLateralService.showGuardar(true, $scope.crearRemito);
47 focaBotoneraLateralService.addCustomButton('Salir', salir); 47 focaBotoneraLateralService.addCustomButton('Salir', salir);
48 }); 48 });
49 49
50 init(); 50 init();
51 } 51 }
52 52
53 function init() { 53 function init() {
54 $scope.$broadcast('cleanCabecera'); 54 $scope.$broadcast('cleanCabecera');
55 $scope.remito = { 55 $scope.remito = {
56 id: 0, 56 id: 0,
57 estado: 0, 57 estado: 0,
58 // vendedor: {}, 58 // vendedor: {},
59 cliente: {}, 59 cliente: {},
60 proveedor: {}, 60 proveedor: {},
61 domicilio: { dom: '' }, 61 domicilio: { dom: '' },
62 moneda: {}, 62 moneda: {},
63 cotizacion: $scope.cotizacionPorDefecto || {}, 63 cotizacion: $scope.cotizacionPorDefecto || {},
64 articulosRemito: [], 64 articulosRemito: [],
65 remitoPuntoDescarga: [] 65 remitoPuntoDescarga: []
66 }; 66 };
67 $scope.notaPedido = { 67 $scope.notaPedido = {
68 id: 0 68 id: 0
69 }; 69 };
70 70
71 $scope.remito.articulosRemito = []; 71 $scope.remito.articulosRemito = [];
72 $scope.idLista = undefined; 72 $scope.idLista = undefined;
73 73
74 crearRemitoService.getNumeroRemito().then( 74 crearRemitoService.getNumeroRemito().then(
75 function (res) { 75 function (res) {
76 $scope.puntoVenta = rellenar(res.data.sucursal, 4); 76 $scope.puntoVenta = rellenar(res.data.sucursal, 4);
77 $scope.comprobante = rellenar(res.data.numeroRemito, 8); 77 $scope.comprobante = rellenar(res.data.numeroRemito, 8);
78 }, 78 },
79 function (err) { 79 function (err) {
80 focaModalService.alert('La terminal no esta configurada correctamente'); 80 focaModalService.alert('La terminal no esta configurada correctamente');
81 console.info(err); 81 console.info(err);
82 } 82 }
83 ); 83 );
84 84
85 $scope.inicial = angular.copy($scope.remito); 85 $scope.inicial = angular.copy($scope.remito);
86 } 86 }
87 87
88 $scope.$watch('remito', function (newValue) { 88 $scope.$watch('remito', function (newValue) {
89 focaBotoneraLateralService.setPausarData({ 89 focaBotoneraLateralService.setPausarData({
90 label: 'remito', 90 label: 'remito',
91 val: newValue 91 val: newValue
92 }); 92 });
93 focaBotoneraLateralService.setRutasPausadas({ 93 focaBotoneraLateralService.setRutasPausadas({
94 label: 'rutas', 94 label: 'rutas',
95 val: 'venta-remito/crear' 95 val: 'venta-remito/crear'
96 }); 96 });
97 }, true); 97 }, true);
98 98
99 $scope.seleccionarNotaPedido = function () { 99 $scope.seleccionarNotaPedido = function () {
100 if ($scope.remitoIsDirty) { 100 if ($scope.remitoIsDirty) {
101 focaModalService.confirm('¿Desea continuar? Se perderan los cambios') 101 focaModalService.confirm('¿Desea continuar? Se perderan los cambios')
102 .then(function () { 102 .then(function () {
103 $scope.getNotaPedidoModal(); 103 $scope.getNotaPedidoModal();
104 }); 104 });
105 } else { 105 } else {
106 $scope.getNotaPedidoModal(); 106 $scope.getNotaPedidoModal();
107 } 107 }
108 }; 108 };
109 109
110 $scope.getNotaPedidoModal = function () { 110 $scope.getNotaPedidoModal = function () {
111 if (!varlidarRemitoFacturado()) return; 111 if (!varlidarRemitoFacturado()) return;
112 if (!varlidarRemitoAbierto()) return; 112 if (!varlidarRemitoAbierto()) return;
113 var modalInstance = $uibModal.open( 113 var modalInstance = $uibModal.open(
114 { 114 {
115 ariaLabelledBy: 'Busqueda de Nota de Pedido', 115 ariaLabelledBy: 'Busqueda de Nota de Pedido',
116 templateUrl: 'foca-modal-nota-pedido.html', 116 templateUrl: 'foca-modal-nota-pedido.html',
117 controller: 'focaModalNotaPedidoController', 117 controller: 'focaModalNotaPedidoController',
118 size: 'lg', 118 size: 'lg',
119 resolve: { 119 resolve: {
120 usadoPor: function () { return 'remito'; }, 120 usadoPor: function () { return 'remito'; },
121 idVendedor: function () { return null; } 121 idVendedor: function () { return null; }
122 } 122 }
123 } 123 }
124 ); 124 );
125 modalInstance.result.then( 125 modalInstance.result.then(
126 function (notaPedido) { 126 function (notaPedido) {
127 //añado cabeceras 127 //añado cabeceras
128 $scope.remitoIsDirty = true; 128 $scope.remitoIsDirty = true;
129 $scope.notaPedido = notaPedido; 129 $scope.notaPedido = notaPedido;
130 $scope.remito.cliente = notaPedido.cliente; 130 $scope.remito.cliente = notaPedido.cliente;
131 $scope.$broadcast('removeCabecera', 'Bomba:'); 131 $scope.$broadcast('removeCabecera', 'Bomba:');
132 $scope.$broadcast('removeCabecera', 'Kilometros:'); 132 $scope.$broadcast('removeCabecera', 'Kilometros:');
133 var puntosDescarga = []; 133 var puntosDescarga = [];
134 notaPedido.notaPedidoPuntoDescarga.forEach(function (notaPedido) { 134 notaPedido.notaPedidoPuntoDescarga.forEach(function (notaPedido) {
135 puntosDescarga.push(notaPedido.puntoDescarga); 135 puntosDescarga.push(notaPedido.puntoDescarga);
136 }); 136 });
137 $scope.cabeceras = [ 137 $scope.cabeceras = [
138 { 138 {
139 label: 'Cliente:', 139 label: 'Cliente:',
140 valor: $filter('rellenarDigitos')(notaPedido.cliente.COD, 3) + 140 valor: $filter('rellenarDigitos')(notaPedido.cliente.COD, 3) +
141 ' - ' + notaPedido.cliente.NOM 141 ' - ' + notaPedido.cliente.NOM
142 }, 142 },
143 { 143 {
144 label: 'Domicilio:', 144 label: 'Domicilio:',
145 valor: notaPedido.domicilioStamp 145 valor: notaPedido.domicilioStamp
146 }, 146 },
147 // { 147 // {
148 // label: 'Vendedor:', 148 // label: 'Vendedor:',
149 // valor: $filter('rellenarDigitos')( 149 // valor: $filter('rellenarDigitos')(
150 // notaPedido.vendedor.NUM, 3 150 // notaPedido.vendedor.NUM, 3
151 // ) + ' - ' + notaPedido.vendedor.NOM 151 // ) + ' - ' + notaPedido.vendedor.NOM
152 // }, 152 // },
153 153
154 { 154 {
155 label: 'Proveedor:', 155 label: 'Proveedor:',
156 valor: $filter('rellenarDigitos') 156 valor: $filter('rellenarDigitos')
157 (notaPedido.proveedor.COD, 5) + ' - ' + 157 (notaPedido.proveedor.COD, 5) + ' - ' +
158 notaPedido.proveedor.NOM 158 notaPedido.proveedor.NOM
159 }, 159 },
160 160
161 { 161 {
162 label: 'Flete:', 162 label: 'Flete:',
163 valor: notaPedido.fob === 1 ? 'FOB' : ( 163 valor: notaPedido.fob === 1 ? 'FOB' : (
164 notaPedido.flete === 1 ? 'Si' : 'No') 164 notaPedido.flete === 1 ? 'Si' : 'No')
165 }, 165 },
166 { 166 {
167 label: 'Puntos de descarga: ', 167 label: 'Puntos de descarga: ',
168 valor: $filter('rellenarDigitos')( 168 valor: $filter('rellenarDigitos')(
169 getCabeceraPuntoDescarga(puntosDescarga)) 169 getCabeceraPuntoDescarga(puntosDescarga))
170 } 170 }
171 ]; 171 ];
172 actualizarCabeceraMoneda(notaPedido.cotizacion); 172 actualizarCabeceraMoneda(notaPedido.cotizacion);
173 valorPrecioCondicion(); 173 valorPrecioCondicion();
174 // Seteo checked en cabeceras 174 // Seteo checked en cabeceras
175 $filter('filter')($scope.botonera, 175 $filter('filter')($scope.botonera,
176 { label: 'Cliente' })[0].checked = true; 176 { label: 'Cliente' })[0].checked = true;
177 $filter('filter')($scope.botonera, 177 $filter('filter')($scope.botonera,
178 { label: 'Proveedor' })[0].checked = true; 178 { label: 'Proveedor' })[0].checked = true;
179 $filter('filter')($scope.botonera, 179 $filter('filter')($scope.botonera,
180 { label: 'Moneda' })[0].checked = true; 180 { label: 'Moneda' })[0].checked = true;
181 $filter('filter')($scope.botonera, 181 $filter('filter')($scope.botonera,
182 { label: 'Nota pedido' })[0].checked = true; 182 { label: 'Nota pedido' })[0].checked = true;
183 $filter('filter')($scope.botonera, 183 $filter('filter')($scope.botonera,
184 { label: 'Precios y condiciones' })[0].checked = true; 184 { label: 'Precios y condiciones' })[0].checked = true;
185 $filter('filter')($scope.botonera, 185 $filter('filter')($scope.botonera,
186 { label: 'Domicilio de Entrega' })[0].checked = true; 186 { label: 'Domicilio de Entrega' })[0].checked = true;
187 187
188 if (notaPedido.observaciones) { 188 if (notaPedido.observaciones) {
189 $filter('filter')($scope.botonera, 189 $filter('filter')($scope.botonera,
190 { label: 'Observaciones' })[0].checked = true; 190 { label: 'Observaciones' })[0].checked = true;
191 } 191 }
192 192
193 function valorPrecioCondicion() { 193 function valorPrecioCondicion() {
194 if (parseInt(notaPedido.idListaPrecio) > 0) { 194 if (parseInt(notaPedido.idListaPrecio) > 0) {
195 crearRemitoService 195 crearRemitoService
196 .getListaPrecioById(parseInt(notaPedido.idListaPrecio)) 196 .getListaPrecioById(parseInt(notaPedido.idListaPrecio))
197 .then(function (res) { 197 .then(function (res) {
198 $scope.cabeceras.push({ 198 $scope.cabeceras.push({
199 label: 'Precios y Condiciones:', 199 label: 'Precios y Condiciones:',
200 valor: 200 valor:
201 parseInt(res.data[0].ID) + ' - ' + 201 parseInt(res.data[0].ID) + ' - ' +
202 res.data[0].DES + ' ' + 202 res.data[0].DES + ' ' +
203 remitoBusinessService 203 remitoBusinessService
204 .plazoToString(notaPedido.notaPedidoPlazo) 204 .plazoToString(notaPedido.notaPedidoPlazo)
205 }); 205 });
206 addArrayCabecera($scope.cabeceras); 206 addArrayCabecera($scope.cabeceras);
207 }); 207 });
208 } 208 }
209 } 209 }
210 210
211 if (notaPedido.flete === 1) { 211 if (notaPedido.flete === 1) {
212 var cabeceraBomba = { 212 var cabeceraBomba = {
213 label: 'Bomba:', 213 label: 'Bomba:',
214 valor: notaPedido.bomba === 1 ? 'Si' : 'No' 214 valor: notaPedido.bomba === 1 ? 'Si' : 'No'
215 }; 215 };
216 if (notaPedido.kilometros) { 216 if (notaPedido.kilometros) {
217 var cabeceraKilometros = { 217 var cabeceraKilometros = {
218 label: 'Kilometros:', 218 label: 'Kilometros:',
219 valor: notaPedido.kilometros 219 valor: notaPedido.kilometros
220 }; 220 };
221 $scope.cabeceras.push(cabeceraKilometros); 221 $scope.cabeceras.push(cabeceraKilometros);
222 } 222 }
223 $scope.cabeceras.push(cabeceraBomba); 223 $scope.cabeceras.push(cabeceraBomba);
224 } 224 }
225 225
226 $scope.remito = angular.copy(notaPedido); 226 $scope.remito = angular.copy(notaPedido);
227 $scope.remito.id = 0; 227 $scope.remito.id = 0;
228 $scope.remito.remitoPlazo = notaPedido.notaPedidoPlazo; 228 $scope.remito.remitoPlazo = notaPedido.notaPedidoPlazo;
229 $scope.remito.remitoPuntoDescarga = notaPedido.notaPedidoPuntoDescarga; 229 $scope.remito.remitoPuntoDescarga = notaPedido.notaPedidoPuntoDescarga;
230 230
231 notaPedido.articulosNotaPedido.forEach(function (articulo) { 231 notaPedido.articulosNotaPedido.forEach(function (articulo) {
232 articulo.id = 0; 232 articulo.id = 0;
233 articulo.idRemito = 0; 233 articulo.idRemito = 0;
234 articulo.precio = 234 articulo.precio =
235 (articulo.precio / notaPedido.cotizacion.VENDEDOR).toFixed(4); 235 (articulo.precio / notaPedido.cotizacion.VENDEDOR).toFixed(4);
236 }); 236 });
237 237
238 $scope.remito.articulosRemito = notaPedido.articulosNotaPedido; 238 $scope.remito.articulosRemito = notaPedido.articulosNotaPedido;
239 239
240 if (notaPedido.idPrecioCondicion > 0) { 240 if (notaPedido.idPrecioCondicion > 0) {
241 $scope.idLista = notaPedido.precioCondicion.idListaPrecio; 241 $scope.idLista = notaPedido.precioCondicion.idListaPrecio;
242 } else { 242 } else {
243 $scope.idLista = -1; 243 $scope.idLista = -1;
244 } 244 }
245 245
246 enableObservaciones(notaPedido.observaciones ? true : false); 246 enableObservaciones(notaPedido.observaciones ? true : false);
247 addArrayCabecera($scope.cabeceras); 247 addArrayCabecera($scope.cabeceras);
248 248
249 }, function () { 249 }, function () {
250 // funcion ejecutada cuando se cancela el modal 250 // funcion ejecutada cuando se cancela el modal
251 } 251 }
252 ); 252 );
253 }; 253 };
254 254
255 $scope.seleccionarRemito = function () { 255 $scope.seleccionarRemito = function () {
256 if ($scope.remitoIsDirty) { 256 if ($scope.remitoIsDirty) {
257 focaModalService.confirm('¿Desea continuar? Se perderan los cambios') 257 focaModalService.confirm('¿Desea continuar? Se perderan los cambios')
258 .then(function () { 258 .then(function () {
259 $scope.getRemitoModal(); 259 $scope.getRemitoModal();
260 }); 260 });
261 } else { 261 } else {
262 $scope.getRemitoModal(); 262 $scope.getRemitoModal();
263 } 263 }
264 }; 264 };
265 $scope.getRemitoModal = function () { 265 $scope.getRemitoModal = function () {
266 var modalInstance = $uibModal.open( 266 var modalInstance = $uibModal.open(
267 { 267 {
268 ariaLabelledBy: 'Busqueda de Remito', 268 ariaLabelledBy: 'Busqueda de Remito',
269 templateUrl: 'foca-modal-remito.html', 269 templateUrl: 'foca-modal-remito.html',
270 controller: 'focaModalRemitoController', 270 controller: 'focaModalRemitoController',
271 size: 'lg', 271 size: 'lg',
272 resolve: { usadoPor: function () { return 'remito'; } } 272 resolve: { usadoPor: function () { return 'remito'; } }
273 } 273 }
274 ); 274 );
275 modalInstance.result.then(function (remito) { 275 modalInstance.result.then(function (remito) {
276 276
277 remito.articulosRemito.forEach(function (articulo) { 277 remito.articulosRemito.forEach(function (articulo) {
278 articulo.precio = 278 articulo.precio =
279 (articulo.precio / remito.cotizacion.VENDEDOR).toFixed(4); 279 (articulo.precio / remito.cotizacion.VENDEDOR).toFixed(4);
280 }); 280 });
281 281
282 setearRemito(remito); 282 setearRemito(remito);
283 283
284 }, function () { 284 }, function () {
285 // funcion ejecutada cuando se cancela el modal 285 // funcion ejecutada cuando se cancela el modal
286 } 286 }
287 ); 287 );
288 }; 288 };
289 //validacion por domicilio y por plazo pago 289 //validacion por domicilio y por plazo pago
290 $scope.crearRemito = function () { 290 $scope.crearRemito = function () {
291 291
292 if (!remitoBusinessService.validarRemito($scope.remito, $scope.articulosFiltro())) { 292 if (!remitoBusinessService.validarRemito($scope.remito, $scope.articulosFiltro())) {
293 return; 293 return;
294 } 294 }
295 295
296 focaBotoneraLateralService.startGuardar(); 296 focaBotoneraLateralService.startGuardar();
297 $scope.saveLoading = true; 297 $scope.saveLoading = true;
298 var rutaJson = JSON.parse($localStorage.rutas); 298 var rutaJson = JSON.parse($localStorage.rutas);
299 removeItemFromArr(rutaJson, 'venta-remito/crear'); 299 removeItemFromArr(rutaJson, 'venta-remito/crear');
300 $localStorage.rutas = JSON.stringify(rutaJson); 300 $localStorage.rutas = JSON.stringify(rutaJson);
301 301
302 var save = { 302 var save = {
303 remito: { 303 remito: {
304 id: $scope.remito.id, 304 id: $scope.remito.id,
305 fechaRemito: $scope.now.toISOString().slice(0, 19).replace('T', ' '), 305 fechaRemito: $scope.now.toISOString().slice(0, 19).replace('T', ' '),
306 idCliente: $scope.remito.cliente.COD, 306 idCliente: $scope.remito.cliente.COD,
307 nombreCliente: $scope.remito.cliente.NOM, 307 nombreCliente: $scope.remito.cliente.NOM,
308 cuitCliente: $scope.remito.cliente.CUIT, 308 cuitCliente: $scope.remito.cliente.CUIT,
309 total: $scope.getTotal() * $scope.remito.cotizacion.VENDEDOR, 309 total: $scope.getTotal() * $scope.remito.cotizacion.VENDEDOR,
310 numeroNotaPedido: $scope.remito.numeroNotaPedido, 310 numeroNotaPedido: $scope.remito.numeroNotaPedido,
311 idVendedor: parseInt($scope.remito.cliente.VEN), 311 idVendedor: parseInt($scope.remito.cliente.VEN),
312 idProveedor: $scope.remito.proveedor.COD, 312 idProveedor: $scope.remito.proveedor.COD,
313 idDomicilio: $scope.remito.idDomicilio || $scope.remito.domicilio.id, 313 idDomicilio: $scope.remito.idDomicilio || $scope.remito.domicilio.id,
314 idCotizacion: $scope.remito.cotizacion.ID, 314 idCotizacion: $scope.remito.cotizacion.ID,
315 idListaPrecio: $scope.idLista, 315 idListaPrecio: $scope.idLista,
316 flete: $scope.remito.flete, 316 flete: $scope.remito.flete,
317 fob: $scope.remito.fob, 317 fob: $scope.remito.fob,
318 bomba: $scope.remito.bomba, 318 bomba: $scope.remito.bomba,
319 kilometros: $scope.remito.kilometros, 319 kilometros: $scope.remito.kilometros,
320 domicilioStamp: $scope.remito.domicilioStamp, 320 domicilioStamp: $scope.remito.domicilioStamp,
321 observaciones: $scope.remito.observaciones, 321 observaciones: $scope.remito.observaciones,
322 numeroRemito: parseInt($scope.comprobante), 322 numeroRemito: parseInt($scope.comprobante),
323 sucursal: parseInt($scope.puntoVenta), 323 sucursal: parseInt($scope.puntoVenta),
324 responsabilidadIvaCliente: $scope.remito.cliente.IVA, 324 responsabilidadIvaCliente: $scope.remito.cliente.IVA,
325 descuento: 0,//TODO, 325 descuento: 0,//TODO,
326 importeNeto: getImporte('netoUnitario'), 326 importeNeto: getImporte('netoUnitario'),
327 importeExento: getImporte('exentoUnitario'), 327 importeExento: getImporte('exentoUnitario'),
328 importeIva: getImporte('ivaUnitario'), 328 importeIva: getImporte('ivaUnitario'),
329 importeIvaServicios: 0,//TODO 329 importeIvaServicios: 0,//TODO
330 importeImpuestoInterno: getImporte('impuestoInternoUnitario'), 330 importeImpuestoInterno: getImporte('impuestoInternoUnitario'),
331 importeImpuestoInterno1: getImporte('impuestoInterno1Unitario'), 331 importeImpuestoInterno1: getImporte('impuestoInterno1Unitario'),
332 importeImpuestoInterno2: getImporte('impuestoInterno2Unitario'), 332 importeImpuestoInterno2: getImporte('impuestoInterno2Unitario'),
333 percepcion: 0,//TODO 333 percepcion: 0,//TODO
334 percepcionIva: 0,//TODO 334 percepcionIva: 0,//TODO
335 redondeo: 0,//TODO 335 redondeo: 0,//TODO
336 anulado: false, 336 anulado: false,
337 planilla: $filter('date')($scope.now, 'ddMMyyyy'), 337 planilla: $filter('date')($scope.now, 'ddMMyyyy'),
338 lugar: parseInt($scope.puntoVenta), 338 lugar: parseInt($scope.puntoVenta),
339 cuentaMadre: 0,//TODO 339 cuentaMadre: 0,//TODO
340 cuentaContable: 0,//TODO 340 cuentaContable: 0,//TODO
341 asiento: 0,//TODO 341 asiento: 0,//TODO
342 e_hd: '',//TODO 342 e_hd: '',//TODO
343 c_hd: '', 343 c_hd: '',
344 numeroLiquidoProducto: 0,//TODO 344 numeroLiquidoProducto: 0,//TODO
345 estado: $scope.remito.estado, 345 estado: $scope.remito.estado,
346 destinoVenta: 0,//TODO 346 destinoVenta: 0,//TODO
347 operacionTipo: 0, //TODO 347 operacionTipo: 0, //TODO
348 }, 348 },
349 notaPedido: $scope.notaPedido, 349 notaPedido: $scope.notaPedido,
350 articulos: remitoBusinessService.quitarCotizacion($scope.articulosFiltro(), 350 articulos: remitoBusinessService.quitarCotizacion($scope.articulosFiltro(),
351 $scope.remito.cotizacion.VENDEDOR), 351 $scope.remito.cotizacion.VENDEDOR),
352 puntosDescarga: remitoBusinessService.addPuntosDescarga( 352 puntosDescarga: remitoBusinessService.addPuntosDescarga(
353 $scope.remito.remitoPuntoDescarga), 353 $scope.remito.remitoPuntoDescarga),
354 plazos: $scope.remito.remitoPlazo 354 plazos: $scope.remito.remitoPlazo
355 }; 355 };
356 crearRemitoService.crearRemito(save).then( 356 crearRemitoService.crearRemito(save).then(
357 function (data) { 357 function (data) {
358 358
359 focaBotoneraLateralService.endGuardar(true); 359 focaBotoneraLateralService.endGuardar(true);
360 $scope.saveLoading = false; 360 $scope.saveLoading = false;
361 361
362 if (data.status === 500) { 362 if (data.status === 500) {
363 focaModalService.alert(data.data); 363 focaModalService.alert(data.data);
364 return; 364 return;
365 } 365 }
366 366
367 abrirModalMail(data.data.id, 367 abrirModalMail(data.data.id,
368 $scope.remito.cliente, 368 $scope.remito.cliente,
369 $filter('comprobante')([ 369 $filter('comprobante')([
370 $scope.puntoVenta, 370 $scope.puntoVenta,
371 data.data.numero 371 data.data.numero
372 ]) 372 ])
373 ); 373 );
374 374
375 config(); 375 config();
376 376
377 }, function (error) { 377 }, function (error) {
378 focaModalService.alert(error.data || 'Hubo un error al crear el remito'); 378 focaModalService.alert(error.data || 'Hubo un error al crear el remito');
379 focaBotoneraLateralService.endGuardar(); 379 focaBotoneraLateralService.endGuardar();
380 $scope.saveLoading = false; 380 $scope.saveLoading = false;
381 console.info(error); 381 console.info(error);
382 } 382 }
383 ); 383 );
384 }; 384 };
385 385
386 $scope.seleccionarProductos = function () { 386 $scope.seleccionarProductos = function () {
387 if (!varlidarRemitoFacturado()) return; 387 if (!varlidarRemitoFacturado()) return;
388 if (!varlidarRemitoAbierto()) return; 388 if (!varlidarRemitoAbierto()) return;
389 if ($scope.notaPedido.id !== 0) { 389 if ($scope.notaPedido.id !== 0) {
390 $scope.idLista = parseInt($scope.notaPedido.idListaPrecio); 390 $scope.idLista = parseInt($scope.notaPedido.idListaPrecio);
391 } 391 }
392 if ($scope.idLista === undefined) { 392 if ($scope.idLista === undefined) {
393 focaModalService.alert( 393 focaModalService.alert(
394 'Primero seleccione una lista de precio y condicion'); 394 'Primero seleccione una lista de precio y condicion');
395 return; 395 return;
396 } 396 }
397 var modalInstance = $uibModal.open( 397 var modalInstance = $uibModal.open(
398 { 398 {
399 ariaLabelledBy: 'Busqueda de Productos', 399 ariaLabelledBy: 'Busqueda de Productos',
400 templateUrl: 'modal-busqueda-productos.html', 400 templateUrl: 'modal-busqueda-productos.html',
401 controller: 'modalBusquedaProductosCtrl', 401 controller: 'modalBusquedaProductosCtrl',
402 resolve: { 402 resolve: {
403 parametroProducto: { 403 parametroProducto: {
404 idLista: $scope.idLista, 404 idLista: $scope.idLista,
405 cotizacion: $scope.remito.cotizacion.VENDEDOR, 405 cotizacion: $scope.remito.cotizacion.VENDEDOR,
406 simbolo: $scope.remito.cotizacion.moneda.SIMBOLO 406 simbolo: $scope.remito.cotizacion.moneda.SIMBOLO
407 } 407 }
408 }, 408 },
409 size: 'lg' 409 size: 'lg'
410 } 410 }
411 ); 411 );
412 modalInstance.result.then( 412 modalInstance.result.then(
413 function (producto) { 413 function (producto) {
414 var newArt = 414 var newArt =
415 { 415 {
416 id: 0, 416 id: 0,
417 idRemito: 0, 417 idRemito: 0,
418 codigo: producto.codigo, 418 codigo: producto.codigo,
419 sector: producto.sector, 419 sector: producto.sector,
420 sectorCodigo: producto.sector + '-' + producto.codigo, 420 sectorCodigo: producto.sector + '-' + producto.codigo,
421 descripcion: producto.descripcionLarga, 421 descripcion: producto.descripcionLarga,
422 item: $scope.remito.articulosRemito.length + 1, 422 item: $scope.remito.articulosRemito.length + 1,
423 nombre: producto.descripcion, 423 nombre: producto.descripcion,
424 precio: parseFloat(producto.precio.toFixed(4)), 424 precio: parseFloat(producto.precio.toFixed(4)),
425 costoUnitario: producto.costo, 425 costoUnitario: producto.costo,
426 editCantidad: false, 426 editCantidad: false,
427 editPrecio: false, 427 editPrecio: false,
428 rubro: producto.CodRub, 428 rubro: producto.CodRub,
429 ivaUnitario: producto.IMPIVA, 429 ivaUnitario: producto.IMPIVA,
430 impuestoInternoUnitario: producto.ImpInt, 430 impuestoInternoUnitario: producto.ImpInt,
431 impuestoInterno1Unitario: producto.ImpInt2, 431 impuestoInterno1Unitario: producto.ImpInt2,
432 impuestoInterno2Unitario: producto.ImpInt3, 432 impuestoInterno2Unitario: producto.ImpInt3,
433 precioLista: producto.precio, 433 precioLista: producto.precio,
434 combustible: 1, 434 combustible: 1,
435 facturado: 0, 435 facturado: 0,
436 idArticulo: producto.id, 436 idArticulo: producto.id,
437 tasaIva: producto.tasaIVA 437 tasaIva: producto.tasaIVA
438 }; 438 };
439 439
440 newArt.exentoUnitario = newArt.ivaUnitario ? 0 : producto.neto; 440 newArt.exentoUnitario = newArt.ivaUnitario ? 0 : producto.neto;
441 newArt.netoUnitario = newArt.ivaUnitario ? producto.neto : 0; 441 newArt.netoUnitario = newArt.ivaUnitario ? producto.neto : 0;
442 442
443 $scope.articuloACargar = newArt; 443 $scope.articuloACargar = newArt;
444 $scope.cargando = false; 444 $scope.cargando = false;
445 }, function () { 445 }, function () {
446 // funcion ejecutada cuando se cancela el modal 446 // funcion ejecutada cuando se cancela el modal
447 } 447 }
448 ); 448 );
449 }; 449 };
450 450
451 $scope.seleccionarPuntosDeDescarga = function () { 451 $scope.seleccionarPuntosDeDescarga = function () {
452 if (!$scope.remito.cliente.COD || !$scope.remito.domicilio.id) { 452 if (!$scope.remito.cliente.COD || !$scope.remito.domicilio.id) {
453 focaModalService.alert('Primero seleccione un cliente y un domicilio'); 453 focaModalService.alert('Primero seleccione un cliente y un domicilio');
454 return; 454 return;
455 } else { 455 } else {
456 var modalInstance = $uibModal.open( 456 var modalInstance = $uibModal.open(
457 { 457 {
458 ariaLabelledBy: 'Búsqueda de Puntos de descarga', 458 ariaLabelledBy: 'Búsqueda de Puntos de descarga',
459 templateUrl: 'modal-punto-descarga.html', 459 templateUrl: 'modal-punto-descarga.html',
460 controller: 'focaModalPuntoDescargaController', 460 controller: 'focaModalPuntoDescargaController',
461 size: 'lg', 461 size: 'lg',
462 resolve: { 462 resolve: {
463 filters: { 463 filters: {
464 idDomicilio: $scope.remito.domicilio.id, 464 idDomicilio: $scope.remito.domicilio.id,
465 idCliente: $scope.remito.cliente.COD, 465 idCliente: $scope.remito.cliente.COD,
466 articulos: $scope.remito.articulosRemito, 466 articulos: $scope.remito.articulosRemito,
467 puntosDescarga: $scope.remito.remitoPuntoDescarga, 467 puntosDescarga: $scope.remito.remitoPuntoDescarga,
468 domicilio: $scope.remito.domicilio 468 domicilio: $scope.remito.domicilio
469 } 469 }
470 } 470 }
471 } 471 }
472 ); 472 );
473 modalInstance.result.then( 473 modalInstance.result.then(
474 function (puntosDescarga) { 474 function (puntosDescarga) {
475 475
476 puntosDescarga.forEach(function (punto) { 476 puntosDescarga.forEach(function (punto) {
477 $scope.remito.remitoPuntoDescarga.push( 477 $scope.remito.remitoPuntoDescarga.push(
478 { 478 {
479 puntoDescarga: punto 479 puntoDescarga: punto
480 } 480 }
481 ); 481 );
482 }); 482 });
483 483
484 $scope.$broadcast('addCabecera', { 484 $scope.$broadcast('addCabecera', {
485 label: 'Puntos de descarga:', 485 label: 'Puntos de descarga:',
486 valor: getCabeceraPuntoDescarga(puntosDescarga) 486 valor: getCabeceraPuntoDescarga(puntosDescarga)
487 }); 487 });
488 }, function () { 488 }, function () {
489 $scope.abrirModalDomicilios($scope.cliente); 489 $scope.abrirModalDomicilios($scope.cliente);
490 } 490 }
491 ); 491 );
492 } 492 }
493 }; 493 };
494 494
495 $scope.seleccionarCliente = function () { 495 $scope.seleccionarCliente = function () {
496 if (!varlidarRemitoFacturado()) return; 496 if (!varlidarRemitoFacturado()) return;
497 if (!varlidarRemitoAbierto()) return; 497 if (!varlidarRemitoAbierto()) return;
498 var modalInstance = $uibModal.open( 498 var modalInstance = $uibModal.open(
499 { 499 {
500 ariaLabelledBy: 'Busqueda de Cliente', 500 ariaLabelledBy: 'Busqueda de Cliente',
501 templateUrl: 'foca-busqueda-cliente-modal.html', 501 templateUrl: 'foca-busqueda-cliente-modal.html',
502 controller: 'focaBusquedaClienteModalController', 502 controller: 'focaBusquedaClienteModalController',
503 resolve: { 503 resolve: {
504 parametros: function () { 504 parametros: function () {
505 return { 505 return {
506 // vendedor: $scope.idVendedor, 506 // vendedor: $scope.idVendedor,
507 cobrador: null, 507 cobrador: null,
508 searchText: $scope.cliente ? $scope.cliente.nom : '' 508 searchText: $scope.cliente ? $scope.cliente.nom : ''
509 }; 509 };
510 }, 510 },
511 }, 511 },
512 backdrop: false,
512 size: 'lg' 513 size: 'lg'
513 } 514 }
514 ); 515 );
515 modalInstance.result.then( 516 modalInstance.result.then(
516 function (cliente) { 517 function (cliente) {
517 518
518 if ($scope.remito.precioCondicion !== undefined) { 519 if ($scope.remito.precioCondicion !== undefined) {
519 focaModalService 520 focaModalService
520 .alert('Debe agregar lista de precio de cliente actual') 521 .alert('Debe agregar lista de precio de cliente actual')
521 .then(function () { 522 .then(function () {
522 $scope.remito.precioCondicion = undefined; 523 $scope.remito.precioCondicion = undefined;
523 $scope.$broadcast('removeCabecera', 'Precios y Condiciones:'); 524 $scope.$broadcast('removeCabecera', 'Precios y Condiciones:');
524 $filter('filter')($scope.botonera, 525 $filter('filter')($scope.botonera,
525 { label: 'Precios y Condiciones' })[0].checked = false; 526 { label: 'Precios y Condiciones' })[0].checked = false;
526 }) 527 })
527 .catch(function () { 528 .catch(function () {
528 }) 529 })
529 } 530 }
530 531
531 // if (angular.equals({}, cliente.vendedor)) { 532 // if (angular.equals({}, cliente.vendedor)) {
532 533
533 // focaModalService 534 // focaModalService
534 // .alert('El cliente seleccionado no tiene tiene ' + 535 // .alert('El cliente seleccionado no tiene tiene ' +
535 // 'vendedor asignado.') 536 // 'vendedor asignado.')
536 // .then($scope.seleccionarCliente); 537 // .then($scope.seleccionarCliente);
537 538
538 // return; 539 // return;
539 // } 540 // }
540 541
541 $scope.cliente = cliente; 542 $scope.cliente = cliente;
542 $scope.abrirModalDomicilios(cliente); 543 $scope.abrirModalDomicilios(cliente);
543 }, function () { 544 }, function () {
544 } 545 }
545 ); 546 );
546 }; 547 };
547 548
548 $scope.seleccionarEliminarRemito = function () { 549 $scope.seleccionarEliminarRemito = function () {
549 focaModalService.confirm('¿Desea eliminar este remito?').then(function (data) { 550 focaModalService.confirm('¿Desea eliminar este remito?').then(function (data) {
550 if (data) { 551 if (data) {
551 $scope.remito.anulado = true; 552 $scope.remito.anulado = true;
552 delete $scope.remito.remitoPlazo; 553 delete $scope.remito.remitoPlazo;
553 // delete $scope.remito.vendedor; 554 // delete $scope.remito.vendedor;
554 delete $scope.remito.proveedor; 555 delete $scope.remito.proveedor;
555 delete $scope.remito.cliente; 556 delete $scope.remito.cliente;
556 delete $scope.remito.cotizacion; 557 delete $scope.remito.cotizacion;
557 delete $scope.remito.remitoPuntoDescarga; 558 delete $scope.remito.remitoPuntoDescarga;
558 delete $scope.remito.articulosRemito; 559 delete $scope.remito.articulosRemito;
559 delete $scope.remito.fechaRemito; 560 delete $scope.remito.fechaRemito;
560 crearRemitoService.eliminarRemito($scope.remito); 561 crearRemitoService.eliminarRemito($scope.remito);
561 } 562 }
562 config(); 563 config();
563 }); 564 });
564 }; 565 };
565 566
566 $scope.seleccionarProveedor = function () { 567 $scope.seleccionarProveedor = function () {
567 if (!varlidarRemitoFacturado()) return; 568 if (!varlidarRemitoFacturado()) return;
568 if (!varlidarRemitoAbierto()) return; 569 if (!varlidarRemitoAbierto()) return;
569 var parametrosModal = { 570 var parametrosModal = {
570 titulo: 'Búsqueda de Proveedor', 571 titulo: 'Búsqueda de Proveedor',
571 query: '/proveedor', 572 query: '/proveedor',
572 columnas: [ 573 columnas: [
573 { 574 {
574 nombre: 'Código', 575 nombre: 'Código',
575 propiedad: 'COD', 576 propiedad: 'COD',
576 filtro: { 577 filtro: {
577 nombre: 'rellenarDigitos', 578 nombre: 'rellenarDigitos',
578 parametro: 5 579 parametro: 5
579 } 580 }
580 }, 581 },
581 { 582 {
582 nombre: 'Nombre', 583 nombre: 'Nombre',
583 propiedad: 'NOM' 584 propiedad: 'NOM'
584 }, 585 },
585 { 586 {
586 nombre: 'CUIT', 587 nombre: 'CUIT',
587 propiedad: 'CUIT' 588 propiedad: 'CUIT'
588 } 589 }
589 ], 590 ],
590 tipo: 'POST', 591 tipo: 'POST',
591 json: { razonCuitCod: '' } 592 json: { razonCuitCod: '' }
592 }; 593 };
593 focaModalService.modal(parametrosModal).then( 594 focaModalService.modal(parametrosModal).then(
594 function (proveedor) { 595 function (proveedor) {
595 $scope.seleccionarFlete(proveedor); 596 $scope.seleccionarFlete(proveedor);
596 }, function () { } 597 }, function () { }
597 ); 598 );
598 }; 599 };
599 600
600 $scope.seleccionarDomicilioDeEntrega = function () { 601 $scope.seleccionarDomicilioDeEntrega = function () {
601 if (!varlidarRemitoFacturado()) return; 602 if (!varlidarRemitoFacturado()) return;
602 if (!varlidarRemitoAbierto()) return; 603 if (!varlidarRemitoAbierto()) return;
603 if (!$scope.remito.cliente.COD && !$scope.cliente) { 604 if (!$scope.remito.cliente.COD && !$scope.cliente) {
604 focaModalService.alert('Seleccione un Cliente'); 605 focaModalService.alert('Seleccione un Cliente');
605 return; 606 return;
606 } else { 607 } else {
607 $scope.abrirModalDomicilios($scope.remito.cliente.COD ? 608 $scope.abrirModalDomicilios($scope.remito.cliente.COD ?
608 $scope.remito.cliente.COD : $scope.cliente); 609 $scope.remito.cliente.COD : $scope.cliente);
609 } 610 }
610 }; 611 };
611 612
612 $scope.abrirModalDomicilios = function (cliente) { 613 $scope.abrirModalDomicilios = function (cliente) {
613 var modalInstanceDomicilio = $uibModal.open( 614 var modalInstanceDomicilio = $uibModal.open(
614 { 615 {
615 ariaLabelledBy: 'Busqueda de Domicilios', 616 ariaLabelledBy: 'Busqueda de Domicilios',
616 templateUrl: 'modal-domicilio.html', 617 templateUrl: 'modal-domicilio.html',
617 controller: 'focaModalDomicilioController', 618 controller: 'focaModalDomicilioController',
619 backdrop: false,
618 size: 'lg', 620 size: 'lg',
619 resolve: { 621 resolve: {
620 idCliente: function () { 622 idCliente: function () {
621 return $scope.remito.cliente.COD ? $scope.remito.cliente.COD : 623 return $scope.remito.cliente.COD ? $scope.remito.cliente.COD :
622 cliente.COD; 624 cliente.COD;
623 }, 625 },
624 esNuevo: function () { 626 esNuevo: function () {
625 return ($scope.remito.cliente.COD ? false : cliente.esNuevo); 627 return ($scope.remito.cliente.COD ? false : cliente.esNuevo);
626 } 628 }
627 } 629 }
628 } 630 }
629 ); 631 );
630 modalInstanceDomicilio.result 632 modalInstanceDomicilio.result
631 .then(function (domicilio) { 633 .then(function (domicilio) {
632 $scope.remito.domicilio = domicilio; 634 $scope.remito.domicilio = domicilio;
633 $scope.remito.cliente = cliente; 635 $scope.remito.cliente = cliente;
634 // $scope.remito.vendedor = cliente.vendedor; 636 // $scope.remito.vendedor = cliente.vendedor;
635 637
636 var domicilioStamp = 638 var domicilioStamp =
637 domicilio.Calle + ' ' + domicilio.Numero + ', ' + 639 domicilio.Calle + ' ' + domicilio.Numero + ', ' +
638 domicilio.Localidad + ', ' + domicilio.Provincia; 640 domicilio.Localidad + ', ' + domicilio.Provincia;
639 641
640 $scope.remito.domicilioStamp = domicilioStamp; 642 $scope.remito.domicilioStamp = domicilioStamp;
641 643
642 // $scope.$broadcast('addCabecera', { 644 // $scope.$broadcast('addCabecera', {
643 // label: 'Vendedor:', 645 // label: 'Vendedor:',
644 // valor: $filter('rellenarDigitos')($scope.remito.vendedor 646 // valor: $filter('rellenarDigitos')($scope.remito.vendedor
645 // .NUM, 3) + ' - ' + $scope.remito.vendedor.NOM 647 // .NUM, 3) + ' - ' + $scope.remito.vendedor.NOM
646 // }); 648 // });
647 $scope.$broadcast('addCabecera', { 649 $scope.$broadcast('addCabecera', {
648 label: 'Cliente:', 650 label: 'Cliente:',
649 valor: $filter('rellenarDigitos') 651 valor: $filter('rellenarDigitos')
650 ($scope.remito.cliente.COD, 3) + 652 ($scope.remito.cliente.COD, 3) +
651 ' - ' + $scope.remito.cliente.NOM 653 ' - ' + $scope.remito.cliente.NOM
652 }); 654 });
653 $scope.$broadcast('addCabecera', { 655 $scope.$broadcast('addCabecera', {
654 label: 'Domicilio:', 656 label: 'Domicilio:',
655 valor: domicilioStamp 657 valor: domicilioStamp
656 }); 658 });
657 659
658 if (domicilio.verPuntos) { 660 if (domicilio.verPuntos) {
659 delete $scope.remito.domicilio.verPuntos; 661 delete $scope.remito.domicilio.verPuntos;
660 $scope.seleccionarPuntosDeDescarga(); 662 $scope.seleccionarPuntosDeDescarga();
661 } 663 }
662 664
663 $filter('filter')($scope.botonera, 665 $filter('filter')($scope.botonera,
664 { label: 'Cliente' })[0].checked = true; 666 { label: 'Cliente' })[0].checked = true;
665 $filter('filter')($scope.botonera, 667 $filter('filter')($scope.botonera,
666 { label: 'Domicilio de Entrega' })[0].checked = true; 668 { label: 'Domicilio de Entrega' })[0].checked = true;
667 669
668 }) 670 })
669 .catch(function (e) { 671 .catch(function (e) {
670 console.info(e); 672 console.info(e);
671 $scope.seleccionarCliente(true); 673 $scope.seleccionarCliente(true);
672 return; 674 return;
673 }); 675 });
674 }; 676 };
675 677
676 $scope.getTotal = function () { 678 $scope.getTotal = function () {
677 var total = 0; 679 var total = 0;
678 var arrayTempArticulos = $scope.articulosFiltro(); 680 var arrayTempArticulos = $scope.articulosFiltro();
679 for (var i = 0; i < arrayTempArticulos.length; i++) { 681 for (var i = 0; i < arrayTempArticulos.length; i++) {
680 total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; 682 total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad;
681 } 683 }
682 return parseFloat(total.toFixed(2)); 684 return parseFloat(total.toFixed(2));
683 }; 685 };
684 686
685 $scope.getSubTotal = function () { 687 $scope.getSubTotal = function () {
686 if ($scope.articuloACargar) { 688 if ($scope.articuloACargar) {
687 return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; 689 return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad;
688 } 690 }
689 }; 691 };
690 692
691 $scope.seleccionarPreciosYCondiciones = function () { 693 $scope.seleccionarPreciosYCondiciones = function () {
692 if (!$scope.remito.cliente.COD) { 694 if (!$scope.remito.cliente.COD) {
693 focaModalService.alert('Primero seleccione un cliente'); 695 focaModalService.alert('Primero seleccione un cliente');
694 return; 696 return;
695 } 697 }
696 if ($scope.remito.articulosRemito.length !== 0) { 698 if ($scope.remito.articulosRemito.length !== 0) {
697 if (varlidarRemitoFacturado() && varlidarRemitoAbierto()) { 699 if (varlidarRemitoFacturado() && varlidarRemitoAbierto()) {
698 abrirModal(); 700 abrirModal();
699 } 701 }
700 } else { 702 } else {
701 abrirModal(); 703 abrirModal();
702 } 704 }
703 705
704 function abrirModal() { 706 function abrirModal() {
705 var parametros = { 707 var parametros = {
706 idCliente: $scope.remito.cliente.COD, 708 idCliente: $scope.remito.cliente.COD,
707 idListaPrecio: $scope.remito.cliente.MOD 709 idListaPrecio: $scope.remito.cliente.MOD
708 }; 710 };
709 var modalInstance = $uibModal.open( 711 var modalInstance = $uibModal.open(
710 { 712 {
711 ariaLabelledBy: 'Busqueda de Precio Condición', 713 ariaLabelledBy: 'Busqueda de Precio Condición',
712 templateUrl: 'modal-precio-condicion.html', 714 templateUrl: 'modal-precio-condicion.html',
713 controller: 'focaModalPrecioCondicionController', 715 controller: 'focaModalPrecioCondicionController',
714 size: 'lg', 716 size: 'lg',
715 resolve: { 717 resolve: {
716 parametros: function () { return parametros; } 718 parametros: function () { return parametros; }
717 } 719 }
718 } 720 }
719 ); 721 );
720 modalInstance.result.then( 722 modalInstance.result.then(
721 function (precioCondicion) { 723 function (precioCondicion) {
722 var cabecera = ''; 724 var cabecera = '';
723 var plazosConcat = ''; 725 var plazosConcat = '';
724 if (!Array.isArray(precioCondicion)) { 726 if (!Array.isArray(precioCondicion)) {
725 $scope.remito.idPrecioCondicion = precioCondicion.listaPrecio.ID; 727 $scope.remito.idPrecioCondicion = precioCondicion.listaPrecio.ID;
726 $scope.remito.remitoPlazo = precioCondicion.plazoPago; 728 $scope.remito.remitoPlazo = precioCondicion.plazoPago;
727 $scope.idLista = parseInt(precioCondicion.listaPrecio.ID) ? 729 $scope.idLista = parseInt(precioCondicion.listaPrecio.ID) ?
728 parseInt(precioCondicion.listaPrecio.ID) : -1; 730 parseInt(precioCondicion.listaPrecio.ID) : -1;
729 $scope.remito.cliente.MOD = precioCondicion.listaPrecio.ID; 731 $scope.remito.cliente.MOD = precioCondicion.listaPrecio.ID;
730 for (var i = 0; i < precioCondicion.plazoPago.length; i++) { 732 for (var i = 0; i < precioCondicion.plazoPago.length; i++) {
731 plazosConcat += precioCondicion.plazoPago[i].dias + ', '; 733 plazosConcat += precioCondicion.plazoPago[i].dias + ', ';
732 } 734 }
733 plazosConcat = plazosConcat.substring(0, plazosConcat.length - 2); 735 plazosConcat = plazosConcat.substring(0, plazosConcat.length - 2);
734 cabecera = $filter('rellenarDigitos') 736 cabecera = $filter('rellenarDigitos')
735 (parseInt(precioCondicion.listaPrecio.ID), 4) + 737 (parseInt(precioCondicion.listaPrecio.ID), 4) +
736 ' - ' + precioCondicion.listaPrecio.DES + ' ' + 738 ' - ' + precioCondicion.listaPrecio.DES + ' ' +
737 plazosConcat.trim(); 739 plazosConcat.trim();
738 } else { //Cuando se ingresan los plazos manualmente 740 } else { //Cuando se ingresan los plazos manualmente
739 $scope.remito.idPrecioCondicion = 0; 741 $scope.remito.idPrecioCondicion = 0;
740 //-1, el modal productos busca todos los productos 742 //-1, el modal productos busca todos los productos
741 $scope.idLista = -1; 743 $scope.idLista = -1;
742 $scope.remito.remitoPlazo = precioCondicion; 744 $scope.remito.remitoPlazo = precioCondicion;
743 for (var j = 0; j < precioCondicion.length; j++) { 745 for (var j = 0; j < precioCondicion.length; j++) {
744 plazosConcat += precioCondicion[j].dias + ' '; 746 plazosConcat += precioCondicion[j].dias + ' ';
745 } 747 }
746 cabecera = plazosConcat.trim(); 748 cabecera = plazosConcat.trim();
747 } 749 }
748 var cabecerasFilter = !$filter('filter')($scope.cabeceras, 750 var cabecerasFilter = !$filter('filter')($scope.cabeceras,
749 { label: 'Precios y Condiciones' }); 751 { label: 'Precios y Condiciones' });
750 if (!cabecerasFilter) { 752 if (!cabecerasFilter) {
751 $scope.cabeceras.push({ 753 $scope.cabeceras.push({
752 label: 'Precios y Condiciones:', 754 label: 'Precios y Condiciones:',
753 valor: parseInt(precioCondicion.listaPrecio.ID) + ' - ' + 755 valor: parseInt(precioCondicion.listaPrecio.ID) + ' - ' +
754 precioCondicion.listaPrecio.DES + ' ' + 756 precioCondicion.listaPrecio.DES + ' ' +
755 remitoBusinessService 757 remitoBusinessService
756 .plazoToString(precioCondicion.plazoPago) 758 .plazoToString(precioCondicion.plazoPago)
757 }); 759 });
758 760
759 $scope.remito.idListaPrecio = parseInt( 761 $scope.remito.idListaPrecio = parseInt(
760 precioCondicion.listaPrecio.ID); 762 precioCondicion.listaPrecio.ID);
761 } 763 }
762 $filter('filter')($scope.cabeceras, 764 $filter('filter')($scope.cabeceras,
763 { label: 'Precios y Condiciones' })[0].valor = cabecera; 765 { label: 'Precios y Condiciones' })[0].valor = cabecera;
764 766
765 $scope.remito.precioCondicion = precioCondicion; 767 $scope.remito.precioCondicion = precioCondicion;
766 $filter('filter')($scope.botonera, 768 $filter('filter')($scope.botonera,
767 { label: 'Precios y Condiciones' })[0].checked = true; 769 { label: 'Precios y Condiciones' })[0].checked = true;
768 addArrayCabecera($scope.cabeceras); 770 addArrayCabecera($scope.cabeceras);
769 }, function () { 771 }, function () {
770 772
771 } 773 }
772 ); 774 );
773 } 775 }
774 }; 776 };
775 777
776 $scope.seleccionarFlete = function (proveedor) { 778 $scope.seleccionarFlete = function (proveedor) {
777 if (!varlidarRemitoFacturado()) return; 779 if (!varlidarRemitoFacturado()) return;
778 if (!varlidarRemitoAbierto()) return; 780 if (!varlidarRemitoAbierto()) return;
779 var modalInstance = $uibModal.open( 781 var modalInstance = $uibModal.open(
780 { 782 {
781 ariaLabelledBy: 'Busqueda de Flete', 783 ariaLabelledBy: 'Busqueda de Flete',
782 templateUrl: 'modal-flete.html', 784 templateUrl: 'modal-flete.html',
783 controller: 'focaModalFleteController', 785 controller: 'focaModalFleteController',
784 size: 'lg', 786 size: 'lg',
785 resolve: { 787 resolve: {
786 parametrosFlete: 788 parametrosFlete:
787 function () { 789 function () {
788 return { 790 return {
789 flete: $scope.remito.flete ? '1' : 791 flete: $scope.remito.flete ? '1' :
790 ($scope.remito.fob ? 'FOB' : 792 ($scope.remito.fob ? 'FOB' :
791 ($scope.remito.flete === undefined ? 793 ($scope.remito.flete === undefined ?
792 null : '0')), 794 null : '0')),
793 bomba: $scope.remito.bomba ? '1' : 795 bomba: $scope.remito.bomba ? '1' :
794 ($scope.remito.bomba === undefined ? 796 ($scope.remito.bomba === undefined ?
795 null : '0'), 797 null : '0'),
796 kilometros: $scope.remito.kilometros 798 kilometros: $scope.remito.kilometros
797 }; 799 };
798 } 800 }
799 } 801 }
800 } 802 }
801 ); 803 );
802 modalInstance.result.then( 804 modalInstance.result.then(
803 function (datos) { 805 function (datos) {
804 $scope.remitoIsDirty = true; 806 $scope.remitoIsDirty = true;
805 $scope.remito.proveedor = proveedor; 807 $scope.remito.proveedor = proveedor;
806 $scope.remito.idProveedor = proveedor.COD; 808 $scope.remito.idProveedor = proveedor.COD;
807 $scope.$broadcast('addCabecera', { 809 $scope.$broadcast('addCabecera', {
808 label: 'Proveedor:', 810 label: 'Proveedor:',
809 valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + 811 valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' +
810 proveedor.NOM 812 proveedor.NOM
811 }); 813 });
812 814
813 $scope.remito.flete = datos.flete; 815 $scope.remito.flete = datos.flete;
814 $scope.remito.fob = datos.FOB; 816 $scope.remito.fob = datos.FOB;
815 $scope.remito.bomba = datos.bomba; 817 $scope.remito.bomba = datos.bomba;
816 $scope.remito.kilometros = datos.kilometros; 818 $scope.remito.kilometros = datos.kilometros;
817 819
818 $scope.$broadcast('addCabecera', { 820 $scope.$broadcast('addCabecera', {
819 label: 'Flete:', 821 label: 'Flete:',
820 valor: datos.flete ? 'Si' : ($scope.remito.fob ? 'FOB' : 'No') 822 valor: datos.flete ? 'Si' : ($scope.remito.fob ? 'FOB' : 'No')
821 }); 823 });
822 if (datos.flete) { 824 if (datos.flete) {
823 $scope.$broadcast('addCabecera', { 825 $scope.$broadcast('addCabecera', {
824 label: 'Bomba:', 826 label: 'Bomba:',
825 valor: datos.bomba ? 'Si' : 'No' 827 valor: datos.bomba ? 'Si' : 'No'
826 }); 828 });
827 $scope.$broadcast('addCabecera', { 829 $scope.$broadcast('addCabecera', {
828 label: 'Kilometros:', 830 label: 'Kilometros:',
829 valor: datos.kilometros 831 valor: datos.kilometros
830 }); 832 });
831 } else { 833 } else {
832 $scope.$broadcast('removeCabecera', 'Bomba:'); 834 $scope.$broadcast('removeCabecera', 'Bomba:');
833 $scope.$broadcast('removeCabecera', 'Kilometros:'); 835 $scope.$broadcast('removeCabecera', 'Kilometros:');
834 $scope.remito.bomba = false; 836 $scope.remito.bomba = false;
835 $scope.remito.kilometros = null; 837 $scope.remito.kilometros = null;
836 } 838 }
837 839
838 $filter('filter')($scope.botonera, 840 $filter('filter')($scope.botonera,
839 { label: 'Proveedor' })[0].checked = true; 841 { label: 'Proveedor' })[0].checked = true;
840 }, function () { 842 }, function () {
841 $scope.seleccionarTransportista(); 843 $scope.seleccionarTransportista();
842 } 844 }
843 ); 845 );
844 }; 846 };
845 847
846 $scope.seleccionarMoneda = function () { 848 $scope.seleccionarMoneda = function () {
847 if (!varlidarRemitoFacturado()) return; 849 if (!varlidarRemitoFacturado()) return;
848 if (!varlidarRemitoAbierto()) return; 850 if (!varlidarRemitoAbierto()) return;
849 var parametrosModal = { 851 var parametrosModal = {
850 titulo: 'Búsqueda de monedas', 852 titulo: 'Búsqueda de monedas',
851 query: '/moneda', 853 query: '/moneda',
852 columnas: [ 854 columnas: [
853 { 855 {
854 propiedad: 'DETALLE', 856 propiedad: 'DETALLE',
855 nombre: 'Nombre' 857 nombre: 'Nombre'
856 }, 858 },
857 { 859 {
858 propiedad: 'SIMBOLO', 860 propiedad: 'SIMBOLO',
859 nombre: 'Símbolo' 861 nombre: 'Símbolo'
860 } 862 }
861 ], 863 ],
862 size: 'md' 864 size: 'md'
863 }; 865 };
864 focaModalService.modal(parametrosModal).then( 866 focaModalService.modal(parametrosModal).then(
865 function (moneda) { 867 function (moneda) {
866 868
867 if (moneda.ID !== 1) { 869 if (moneda.ID !== 1) {
868 $scope.abrirModalCotizacion(moneda); 870 $scope.abrirModalCotizacion(moneda);
869 return; 871 return;
870 } 872 }
871 873
872 crearRemitoService.getCotizacionByIdMoneda(1) 874 crearRemitoService.getCotizacionByIdMoneda(1)
873 .then(function (res) { 875 .then(function (res) {
874 876
875 cotizacionPArgentino = res.data[0].cotizaciones[0]; 877 cotizacionPArgentino = res.data[0].cotizaciones[0];
876 cotizacionPArgentino.moneda = moneda; 878 cotizacionPArgentino.moneda = moneda;
877 879
878 actualizarCabeceraMoneda(cotizacionPArgentino); 880 actualizarCabeceraMoneda(cotizacionPArgentino);
879 $filter('filter')($scope.botonera, 881 $filter('filter')($scope.botonera,
880 { label: 'Moneda' })[0].checked = true; 882 { label: 'Moneda' })[0].checked = true;
881 $scope.remito.cotizacion = cotizacionPArgentino; 883 $scope.remito.cotizacion = cotizacionPArgentino;
882 }); 884 });
883 }, function () { 885 }, function () {
884 886
885 } 887 }
886 ); 888 );
887 }; 889 };
888 890
889 $scope.seleccionarObservaciones = function () { 891 $scope.seleccionarObservaciones = function () {
890 focaModalService 892 focaModalService
891 .prompt({ 893 .prompt({
892 titulo: 'Observaciones', 894 titulo: 'Observaciones',
893 value: $scope.remito.observaciones, 895 value: $scope.remito.observaciones,
894 textarea: true, 896 textarea: true,
895 readonly: false 897 readonly: false
896 }) 898 })
897 .then(function (observaciones) { 899 .then(function (observaciones) {
898 $scope.remito.observaciones = observaciones; 900 $scope.remito.observaciones = observaciones;
899 }); 901 });
900 }; 902 };
901 903
902 $scope.abrirModalCotizacion = function (moneda) { 904 $scope.abrirModalCotizacion = function (moneda) {
903 var modalInstance = $uibModal.open( 905 var modalInstance = $uibModal.open(
904 { 906 {
905 ariaLabelledBy: 'Busqueda de Cotización', 907 ariaLabelledBy: 'Busqueda de Cotización',
906 templateUrl: 'modal-cotizacion.html', 908 templateUrl: 'modal-cotizacion.html',
907 controller: 'focaModalCotizacionController', 909 controller: 'focaModalCotizacionController',
908 size: 'lg', 910 size: 'lg',
909 resolve: { idMoneda: function () { return moneda.ID; } } 911 resolve: { idMoneda: function () { return moneda.ID; } }
910 } 912 }
911 ); 913 );
912 modalInstance.result.then( 914 modalInstance.result.then(
913 function (cotizacion) { 915 function (cotizacion) {
914 cotizacion.moneda = moneda; 916 cotizacion.moneda = moneda;
915 $scope.remitoIsDirty = true; 917 $scope.remitoIsDirty = true;
916 actualizarCabeceraMoneda(cotizacion); 918 actualizarCabeceraMoneda(cotizacion);
917 $filter('filter')($scope.botonera, 919 $filter('filter')($scope.botonera,
918 { label: 'Moneda' })[0].checked = true; 920 { label: 'Moneda' })[0].checked = true;
919 $scope.remito.cotizacion = cotizacion; 921 $scope.remito.cotizacion = cotizacion;
920 }, function () { 922 }, function () {
921 923
922 } 924 }
923 ); 925 );
924 }; 926 };
925 927
926 function actualizarCabeceraMoneda(cotizacion) { 928 function actualizarCabeceraMoneda(cotizacion) {
927 929
928 $scope.remito.articulosRemito.forEach(function (art) { 930 $scope.remito.articulosRemito.forEach(function (art) {
929 art.precio = (art.precio * $scope.remito.cotizacion.VENDEDOR).toFixed(4); 931 art.precio = (art.precio * $scope.remito.cotizacion.VENDEDOR).toFixed(4);
930 art.precio = (art.precio / cotizacion.VENDEDOR).toFixed(4); 932 art.precio = (art.precio / cotizacion.VENDEDOR).toFixed(4);
931 }); 933 });
932 934
933 if (cotizacion.moneda.DETALLE === 'PESOS ARGENTINOS') { 935 if (cotizacion.moneda.DETALLE === 'PESOS ARGENTINOS') {
934 $scope.$broadcast('removeCabecera', 'Moneda:'); 936 $scope.$broadcast('removeCabecera', 'Moneda:');
935 $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); 937 $scope.$broadcast('removeCabecera', 'Fecha cotizacion:');
936 $scope.$broadcast('removeCabecera', 'Cotizacion:'); 938 $scope.$broadcast('removeCabecera', 'Cotizacion:');
937 } else { 939 } else {
938 $scope.$broadcast('addCabecera', { 940 $scope.$broadcast('addCabecera', {
939 label: 'Moneda:', 941 label: 'Moneda:',
940 valor: cotizacion.moneda.DETALLE 942 valor: cotizacion.moneda.DETALLE
941 }); 943 });
942 $scope.$broadcast('addCabecera', { 944 $scope.$broadcast('addCabecera', {
943 label: 'Fecha cotizacion:', 945 label: 'Fecha cotizacion:',
944 valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') 946 valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy')
945 }); 947 });
946 $scope.$broadcast('addCabecera', { 948 $scope.$broadcast('addCabecera', {
947 label: 'Cotizacion:', 949 label: 'Cotizacion:',
948 valor: $filter('number')(cotizacion.VENDEDOR, '2') 950 valor: $filter('number')(cotizacion.VENDEDOR, '2')
949 }); 951 });
950 } 952 }
951 } 953 }
952 954
953 $scope.agregarATabla = function (key) { 955 $scope.agregarATabla = function (key) {
954 if (key === 13) { 956 if (key === 13) {
955 if (!$scope.articuloACargar.cantidad || !$scope.articuloACargar.precio) { 957 if (!$scope.articuloACargar.cantidad || !$scope.articuloACargar.precio) {
956 focaModalService.alert('El valor debe ser al menos 1'); 958 focaModalService.alert('El valor debe ser al menos 1');
957 return; 959 return;
958 } 960 }
959 delete $scope.articuloACargar.sectorCodigo; 961 delete $scope.articuloACargar.sectorCodigo;
960 $scope.remito.articulosRemito.push($scope.articuloACargar); 962 $scope.remito.articulosRemito.push($scope.articuloACargar);
961 $scope.cargando = true; 963 $scope.cargando = true;
962 } 964 }
963 }; 965 };
964 966
965 $scope.quitarArticulo = function (articulo) { 967 $scope.quitarArticulo = function (articulo) {
966 articulo.idRemito = -1; 968 articulo.idRemito = -1;
967 }; 969 };
968 970
969 $scope.articulosFiltro = function () { 971 $scope.articulosFiltro = function () {
970 972
971 var result = $scope.remito.articulosRemito.filter(function (articulo) { 973 var result = $scope.remito.articulosRemito.filter(function (articulo) {
972 return articulo.idRemito >= 0; 974 return articulo.idRemito >= 0;
973 }); 975 });
974 976
975 // Agrego checked en cabecera si hay datos 977 // Agrego checked en cabecera si hay datos
976 if (result.length) { 978 if (result.length) {
977 $filter('filter')($scope.botonera, { label: 'Productos' })[0].checked = true; 979 $filter('filter')($scope.botonera, { label: 'Productos' })[0].checked = true;
978 } else { 980 } else {
979 $filter('filter')($scope.botonera, { label: 'Productos' })[0].checked = false; 981 $filter('filter')($scope.botonera, { label: 'Productos' })[0].checked = false;
980 } 982 }
981 return result; 983 return result;
982 }; 984 };
983 985
984 $scope.editarArticulo = function (key, articulo, tmpCantidad, tmpPrecio) { 986 $scope.editarArticulo = function (key, articulo, tmpCantidad, tmpPrecio) {
985 if (key === 13) { 987 if (key === 13) {
986 if (!articulo.cantidad || !articulo.precio || !tmpCantidad || !tmpPrecio) { 988 if (!articulo.cantidad || !articulo.precio || !tmpCantidad || !tmpPrecio) {
987 focaModalService.alert('Los valores deben ser al menos 1'); 989 focaModalService.alert('Los valores deben ser al menos 1');
988 return; 990 return;
989 } else if (tmpCantidad === '0' || tmpPrecio === '0') { 991 } else if (tmpCantidad === '0' || tmpPrecio === '0') {
990 focaModalService.alert('Esta ingresando un producto con valor 0'); 992 focaModalService.alert('Esta ingresando un producto con valor 0');
991 } else if (articulo.cantidad < 0 || articulo.precio < 0) { 993 } else if (articulo.cantidad < 0 || articulo.precio < 0) {
992 focaModalService.alert('Los valores no pueden ser negativos'); 994 focaModalService.alert('Los valores no pueden ser negativos');
993 return; 995 return;
994 } 996 }
995 articulo.cantidad = tmpCantidad; 997 articulo.cantidad = tmpCantidad;
996 articulo.precio = tmpPrecio; 998 articulo.precio = tmpPrecio;
997 $scope.getTotal(); 999 $scope.getTotal();
998 articulo.editCantidad = articulo.editPrecio = false; 1000 articulo.editCantidad = articulo.editPrecio = false;
999 } 1001 }
1000 }; 1002 };
1001 1003
1002 $scope.cancelarEditar = function (articulo) { 1004 $scope.cancelarEditar = function (articulo) {
1003 $scope.tmpCantidad = articulo.cantidad; 1005 $scope.tmpCantidad = articulo.cantidad;
1004 $scope.tmpPrecio = articulo.precio; 1006 $scope.tmpPrecio = articulo.precio;
1005 articulo.editCantidad = articulo.editPrecio = false; 1007 articulo.editCantidad = articulo.editPrecio = false;
1006 }; 1008 };
1007 1009
1008 $scope.cambioEdit = function (articulo, propiedad) { 1010 $scope.cambioEdit = function (articulo, propiedad) {
1009 if (propiedad === 'cantidad') { 1011 if (propiedad === 'cantidad') {
1010 articulo.editCantidad = true; 1012 articulo.editCantidad = true;
1011 } else if (propiedad === 'precio') { 1013 } else if (propiedad === 'precio') {
1012 articulo.editPrecio = true; 1014 articulo.editPrecio = true;
1013 } 1015 }
1014 }; 1016 };
1015 1017
1016 $scope.resetFilter = function () { 1018 $scope.resetFilter = function () {
1017 $scope.articuloACargar = {}; 1019 $scope.articuloACargar = {};
1018 $scope.cargando = true; 1020 $scope.cargando = true;
1019 }; 1021 };
1020 //Recibe aviso si el teclado está en uso 1022 //Recibe aviso si el teclado está en uso
1021 $rootScope.$on('usarTeclado', function (event, data) { 1023 $rootScope.$on('usarTeclado', function (event, data) {
1022 if (data) { 1024 if (data) {
1023 $scope.mostrarTeclado = true; 1025 $scope.mostrarTeclado = true;
1024 return; 1026 return;
1025 } 1027 }
1026 $scope.mostrarTeclado = false; 1028 $scope.mostrarTeclado = false;
1027 }); 1029 });
1028 1030
1029 $scope.selectFocus = function ($event) { 1031 $scope.selectFocus = function ($event) {
1030 // Si el teclado esta en uso no selecciona el valor 1032 // Si el teclado esta en uso no selecciona el valor
1031 if ($scope.mostrarTeclado) { 1033 if ($scope.mostrarTeclado) {
1032 return; 1034 return;
1033 } 1035 }
1034 $event.target.select(); 1036 $event.target.select();
1035 }; 1037 };
1036 1038
1037 function addArrayCabecera(array) { 1039 function addArrayCabecera(array) {
1038 for (var i = 0; i < array.length; i++) { 1040 for (var i = 0; i < array.length; i++) {
1039 $scope.$broadcast('addCabecera', { 1041 $scope.$broadcast('addCabecera', {
1040 label: array[i].label, 1042 label: array[i].label,
1041 valor: array[i].valor 1043 valor: array[i].valor
1042 }); 1044 });
1043 } 1045 }
1044 } 1046 }
1045 1047
1046 function rellenar(relleno, longitud) { 1048 function rellenar(relleno, longitud) {
1047 relleno = '' + relleno; 1049 relleno = '' + relleno;
1048 while (relleno.length < longitud) { 1050 while (relleno.length < longitud) {
1049 relleno = '0' + relleno; 1051 relleno = '0' + relleno;
1050 } 1052 }
1051 return relleno; 1053 return relleno;
1052 } 1054 }
1053 1055
1054 function varlidarRemitoFacturado() { 1056 function varlidarRemitoFacturado() {
1055 if ($scope.remito.estado !== 5) { 1057 if ($scope.remito.estado !== 5) {
1056 return true; 1058 return true;
1057 } else { 1059 } else {
1058 focaModalService.alert('No se puede editar un remito facturado'); 1060 focaModalService.alert('No se puede editar un remito facturado');
1059 return false; 1061 return false;
1060 } 1062 }
1061 } 1063 }
1062 1064
1063 function varlidarRemitoAbierto() { 1065 function varlidarRemitoAbierto() {
1064 if (!$scope.remito.hojaRuta) return true; 1066 if (!$scope.remito.hojaRuta) return true;
1065 if ($scope.remito.hojaRuta.abierta !== '1') { 1067 if ($scope.remito.hojaRuta.abierta !== '1') {
1066 return true; 1068 return true;
1067 } else { 1069 } else {
1068 focaModalService.alert('No se puede editar un remito abierto'); 1070 focaModalService.alert('No se puede editar un remito abierto');
1069 return false; 1071 return false;
1070 } 1072 }
1071 } 1073 }
1072 1074
1073 function removeItemFromArr(arr, item) { 1075 function removeItemFromArr(arr, item) {
1074 var i = arr.indexOf(item); 1076 var i = arr.indexOf(item);
1075 1077
1076 if (i !== -1) { 1078 if (i !== -1) {
1077 arr.splice(i, 1); 1079 arr.splice(i, 1);
1078 } 1080 }
1079 } 1081 }
1080 1082
1081 function salir() { 1083 function salir() {
1082 var confirmacion = false; 1084 var confirmacion = false;
1083 1085
1084 if (!angular.equals($scope.remito, $scope.inicial)) { 1086 if (!angular.equals($scope.remito, $scope.inicial)) {
1085 confirmacion = true; 1087 confirmacion = true;
1086 } 1088 }
1087 1089
1088 if (confirmacion) { 1090 if (confirmacion) {
1089 focaModalService.confirm( 1091 focaModalService.confirm(
1090 '¿Está seguro de que desea salir? Se perderán todos los datos cargados.' 1092 '¿Está seguro de que desea salir? Se perderán todos los datos cargados.'
1091 ).then(function (data) { 1093 ).then(function (data) {
1092 if (data) { 1094 if (data) {
1093 $location.path('/'); 1095 $location.path('/');
1094 var rutaJson = JSON.parse($localStorage.rutas); 1096 var rutaJson = JSON.parse($localStorage.rutas);
1095 removeItemFromArr(rutaJson, 'venta-remito/crear'); 1097 removeItemFromArr(rutaJson, 'venta-remito/crear');
1096 $localStorage.rutas = JSON.stringify(rutaJson); 1098 $localStorage.rutas = JSON.stringify(rutaJson);
1097 } 1099 }
1098 }); 1100 });
1099 } else { 1101 } else {
1100 $location.path('/'); 1102 $location.path('/');
1101 } 1103 }
1102 } 1104 }
1103 1105
1104 function enableObservaciones(val) { 1106 function enableObservaciones(val) {
1105 var boton = $scope.botonera.filter(function (botonObs) { 1107 var boton = $scope.botonera.filter(function (botonObs) {
1106 return botonObs.label === 'Observaciones'; 1108 return botonObs.label === 'Observaciones';
1107 }); 1109 });
1108 boton[0].disable = !val; 1110 boton[0].disable = !val;
1109 } 1111 }
1110 1112
1111 function setearRemito(remito) { 1113 function setearRemito(remito) {
1112 //añado cabeceras 1114 //añado cabeceras
1113 var esAbierto = remito.hojaRuta ? 1115 var esAbierto = remito.hojaRuta ?
1114 (remito.hojaRuta.abierta === '1') : false; 1116 (remito.hojaRuta.abierta === '1') : false;
1115 if (remito.estado !== 5 && remito.id && !esAbierto) { 1117 if (remito.estado !== 5 && remito.id && !esAbierto) {
1116 1118
1117 $scope.botonera.forEach(function (boton) { 1119 $scope.botonera.forEach(function (boton) {
1118 1120
1119 if (boton.label === 'Eliminar Remito') { 1121 if (boton.label === 'Eliminar Remito') {
1120 boton.disable = false; 1122 boton.disable = false;
1121 } 1123 }
1122 }); 1124 });
1123 } 1125 }
1124 $scope.$broadcast('removeCabecera', 'Moneda:'); 1126 $scope.$broadcast('removeCabecera', 'Moneda:');
1125 $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); 1127 $scope.$broadcast('removeCabecera', 'Fecha cotizacion:');
1126 $scope.$broadcast('removeCabecera', 'Cotizacion:'); 1128 $scope.$broadcast('removeCabecera', 'Cotizacion:');
1127 // $scope.$broadcast('removeCabecera', 'Vendedor:'); 1129 // $scope.$broadcast('removeCabecera', 'Vendedor:');
1128 1130
1129 $scope.cabeceras = []; 1131 $scope.cabeceras = [];
1130 1132
1131 if (remito.cotizacion && remito.cotizacion.moneda.CODIGO_AFIP !== 'PES') { 1133 if (remito.cotizacion && remito.cotizacion.moneda.CODIGO_AFIP !== 'PES') {
1132 $scope.cabeceras.push({ 1134 $scope.cabeceras.push({
1133 label: 'Moneda:', 1135 label: 'Moneda:',
1134 valor: remito.cotizacion.moneda.DETALLE 1136 valor: remito.cotizacion.moneda.DETALLE
1135 }); 1137 });
1136 $scope.cabeceras.push({ 1138 $scope.cabeceras.push({
1137 label: 'Fecha cotizacion:', 1139 label: 'Fecha cotizacion:',
1138 valor: $filter('date')(remito.cotizacion.FECHA, 1140 valor: $filter('date')(remito.cotizacion.FECHA,
1139 'dd/MM/yyyy') 1141 'dd/MM/yyyy')
1140 }); 1142 });
1141 $scope.cabeceras.push({ 1143 $scope.cabeceras.push({
1142 label: 'Cotizacion:', 1144 label: 'Cotizacion:',
1143 valor: $filter('number')(remito.cotizacion.VENDEDOR, 1145 valor: $filter('number')(remito.cotizacion.VENDEDOR,
1144 '2') 1146 '2')
1145 }); 1147 });
1146 } 1148 }
1147 1149
1148 if (remito.cotizacion && remito.cotizacion.moneda) { 1150 if (remito.cotizacion && remito.cotizacion.moneda) {
1149 $filter('filter')($scope.botonera, { label: 'Moneda' })[0].checked = true; 1151 $filter('filter')($scope.botonera, { label: 'Moneda' })[0].checked = true;
1150 } 1152 }
1151 1153
1152 if (remito.cliente && remito.cliente.COD) { 1154 if (remito.cliente && remito.cliente.COD) {
1153 $scope.cabeceras.push({ 1155 $scope.cabeceras.push({
1154 label: 'Cliente:', 1156 label: 'Cliente:',
1155 valor: $filter('rellenarDigitos')(remito.cliente.COD, 3) + ' - ' + 1157 valor: $filter('rellenarDigitos')(remito.cliente.COD, 3) + ' - ' +
1156 remito.cliente.NOM 1158 remito.cliente.NOM
1157 }); 1159 });
1158 $scope.cabeceras.push({ 1160 $scope.cabeceras.push({
1159 label: 'Domicilio:', 1161 label: 'Domicilio:',
1160 valor: remito.domicilioStamp 1162 valor: remito.domicilioStamp
1161 }); 1163 });
1162 1164
1163 $filter('filter')($scope.botonera, 1165 $filter('filter')($scope.botonera,
1164 { label: 'Domicilio de Entrega' })[0].checked = true; 1166 { label: 'Domicilio de Entrega' })[0].checked = true;
1165 $filter('filter')($scope.botonera, { label: 'Cliente' })[0].checked = true; 1167 $filter('filter')($scope.botonera, { label: 'Cliente' })[0].checked = true;
1166 } 1168 }
1167 // if (remito.vendedor && remito.vendedor.NUM) { 1169 // if (remito.vendedor && remito.vendedor.NUM) {
1168 // $scope.cabeceras.push({ 1170 // $scope.cabeceras.push({
1169 // label: 'Vendedor:', 1171 // label: 'Vendedor:',
1170 // valor: $filter('rellenarDigitos')(remito.vendedor.NUM, 3) + 1172 // valor: $filter('rellenarDigitos')(remito.vendedor.NUM, 3) +
1171 // ' - ' + remito.vendedor.NOM 1173 // ' - ' + remito.vendedor.NOM
1172 // }); 1174 // });
1173 // } 1175 // }
1174 if (remito.proveedor && remito.proveedor.COD) { 1176 if (remito.proveedor && remito.proveedor.COD) {
1175 $scope.cabeceras.push({ 1177 $scope.cabeceras.push({
1176 label: 'Proveedor:', 1178 label: 'Proveedor:',
1177 valor: $filter('rellenarDigitos')(remito.proveedor.COD, 5) + 1179 valor: $filter('rellenarDigitos')(remito.proveedor.COD, 5) +
1178 ' - ' + remito.proveedor.NOM 1180 ' - ' + remito.proveedor.NOM
1179 }); 1181 });
1180 1182
1181 $filter('filter')($scope.botonera, { label: 'Proveedor' })[0].checked = true; 1183 $filter('filter')($scope.botonera, { label: 'Proveedor' })[0].checked = true;
1182 } 1184 }
1183 if (remito.flete !== undefined && remito.fob !== undefined) { 1185 if (remito.flete !== undefined && remito.fob !== undefined) {
1184 $scope.cabeceras.push({ 1186 $scope.cabeceras.push({
1185 label: 'Flete:', 1187 label: 'Flete:',
1186 valor: remito.fob ? 'FOB' : ( 1188 valor: remito.fob ? 'FOB' : (
1187 remito.flete ? 'Si' : 'No') 1189 remito.flete ? 'Si' : 'No')
1188 }); 1190 });
1189 } 1191 }
1190 if (remito.remitoPlazo) { 1192 if (remito.remitoPlazo) {
1191 valorPrecioCondicion(); 1193 valorPrecioCondicion();
1192 $filter('filter')($scope.botonera, 1194 $filter('filter')($scope.botonera,
1193 { label: 'Precios y condiciones' })[0].checked = true; 1195 { label: 'Precios y condiciones' })[0].checked = true;
1194 } 1196 }
1195 1197
1196 function valorPrecioCondicion() { 1198 function valorPrecioCondicion() {
1197 if (parseInt(remito.idListaPrecio)) { 1199 if (parseInt(remito.idListaPrecio)) {
1198 crearRemitoService.getListaPrecioById(parseInt(remito.idListaPrecio)) 1200 crearRemitoService.getListaPrecioById(parseInt(remito.idListaPrecio))
1199 .then(function (res) { 1201 .then(function (res) {
1200 $timeout(function () { 1202 $timeout(function () {
1201 $scope.cabeceras.push({ 1203 $scope.cabeceras.push({
1202 label: 'Precios y Condiciones:', 1204 label: 'Precios y Condiciones:',
1203 valor: parseInt(res.data[0].ID) + ' - ' + 1205 valor: parseInt(res.data[0].ID) + ' - ' +
1204 res.data[0].DES + ' ' + 1206 res.data[0].DES + ' ' +
1205 remitoBusinessService 1207 remitoBusinessService
1206 .plazoToString(remito.remitoPlazo) 1208 .plazoToString(remito.remitoPlazo)
1207 }); 1209 });
1208 addArrayCabecera($scope.cabeceras); 1210 addArrayCabecera($scope.cabeceras);
1209 }, true); 1211 }, true);
1210 1212
1211 }); 1213 });
1212 $scope.idLista = parseInt(remito.idListaPrecio); 1214 $scope.idLista = parseInt(remito.idListaPrecio);
1213 } 1215 }
1214 } 1216 }
1215 1217
1216 if (remito.flete === 1) { 1218 if (remito.flete === 1) {
1217 var cabeceraBomba = { 1219 var cabeceraBomba = {
1218 label: 'Bomba', 1220 label: 'Bomba',
1219 valor: remito.bomba === 1 ? 'Si' : 'No' 1221 valor: remito.bomba === 1 ? 'Si' : 'No'
1220 }; 1222 };
1221 if (remito.kilometros) { 1223 if (remito.kilometros) {
1222 var cabeceraKilometros = { 1224 var cabeceraKilometros = {
1223 label: 'Kilometros', 1225 label: 'Kilometros',
1224 valor: remito.kilometros 1226 valor: remito.kilometros
1225 }; 1227 };
1226 $scope.cabeceras.push(cabeceraKilometros); 1228 $scope.cabeceras.push(cabeceraKilometros);
1227 } 1229 }
1228 $scope.cabeceras.push(cabeceraBomba); 1230 $scope.cabeceras.push(cabeceraBomba);
1229 } 1231 }
1230 1232
1231 if (remito.idPrecioCondicion > 0) { 1233 if (remito.idPrecioCondicion > 0) {
1232 $scope.idLista = remito.precioCondicion.idListaPrecio; 1234 $scope.idLista = remito.precioCondicion.idListaPrecio;
1233 } else if (remito.idPrecioCondicion) { 1235 } else if (remito.idPrecioCondicion) {
1234 $scope.idLista = -1; 1236 $scope.idLista = -1;
1235 } 1237 }
1236 $scope.puntoVenta = rellenar(remito.sucursal, 4); 1238 $scope.puntoVenta = rellenar(remito.sucursal, 4);
1237 $scope.comprobante = rellenar(remito.numeroRemito, 8); 1239 $scope.comprobante = rellenar(remito.numeroRemito, 8);
1238 $scope.remito = remito; 1240 $scope.remito = remito;
1239 if ($scope.remito.remitoPuntoDescarga.length) { 1241 if ($scope.remito.remitoPuntoDescarga.length) {
1240 var puntoDescarga = []; 1242 var puntoDescarga = [];
1241 1243
1242 $scope.remito.remitoPuntoDescarga.forEach(function (remitoPuntoDescarga) { 1244 $scope.remito.remitoPuntoDescarga.forEach(function (remitoPuntoDescarga) {
1243 puntoDescarga.push(remitoPuntoDescarga.puntoDescarga); 1245 puntoDescarga.push(remitoPuntoDescarga.puntoDescarga);
1244 }); 1246 });
1245 1247
1246 $scope.cabeceras.push({ 1248 $scope.cabeceras.push({
1247 label: 'Puntos de descarga: ', 1249 label: 'Puntos de descarga: ',
1248 valor: $filter('rellenarDigitos')(getCabeceraPuntoDescarga(puntoDescarga)) 1250 valor: $filter('rellenarDigitos')(getCabeceraPuntoDescarga(puntoDescarga))
1249 }); 1251 });
1250 } 1252 }
1251 $scope.remitoIsDirty = false; 1253 $scope.remitoIsDirty = false;
1252 1254
1253 1255
1254 addArrayCabecera($scope.cabeceras); 1256 addArrayCabecera($scope.cabeceras);
1255 } 1257 }
1256 1258
1257 function getLSRemito() { 1259 function getLSRemito() {
1258 var remito = JSON.parse($localStorage.remito || null); 1260 var remito = JSON.parse($localStorage.remito || null);
1259 if (remito) { 1261 if (remito) {
1260 setearRemito(remito); 1262 setearRemito(remito);
1261 delete $localStorage.remito; 1263 delete $localStorage.remito;
1262 } 1264 }
1263 } 1265 }
1264 1266
1265 function getCabeceraPuntoDescarga(puntosDescarga) { 1267 function getCabeceraPuntoDescarga(puntosDescarga) {
1266 var puntosStamp = ''; 1268 var puntosStamp = '';
1267 puntosDescarga.forEach(function (punto, idx, arr) { 1269 puntosDescarga.forEach(function (punto, idx, arr) {
1268 puntosStamp += punto.descripcion; 1270 puntosStamp += punto.descripcion;
1269 if ((idx + 1) !== arr.length) puntosStamp += ', '; 1271 if ((idx + 1) !== arr.length) puntosStamp += ', ';
1270 }); 1272 });
1271 return puntosStamp; 1273 return puntosStamp;
1272 } 1274 }
1273 1275
1274 function abrirModalMail(id, cliente, numeroRemito) { 1276 function abrirModalMail(id, cliente, numeroRemito) {
1275 focaModalService.mail( 1277 focaModalService.mail(
1276 { 1278 {
1277 titulo: 'Comprobante de remito Nº ' + numeroRemito, 1279 titulo: 'Comprobante de remito Nº ' + numeroRemito,
1278 descarga: { 1280 descarga: {
1279 nombre: numeroRemito + '.pdf', 1281 nombre: numeroRemito + '.pdf',
1280 url: '/remito/comprobante', 1282 url: '/remito/comprobante',
1281 }, 1283 },
1282 descargaSinValorizar: { 1284 descargaSinValorizar: {
1283 nombre: numeroRemito + '.pdf', 1285 nombre: numeroRemito + '.pdf',
1284 url: '/remito/comprobante-sin-valorizar', 1286 url: '/remito/comprobante-sin-valorizar',
1285 }, 1287 },
1286 envio: { 1288 envio: {
1287 mailCliente: cliente.MAIL, 1289 mailCliente: cliente.MAIL,
1288 url: '/remito/mail', 1290 url: '/remito/mail',
1289 }, 1291 },
1290 envioSinValorizar:{ 1292 envioSinValorizar:{
1291 mailCliente: cliente.MAIL, 1293 mailCliente: cliente.MAIL,
1292 url: '/remito/mail-sin-valorizar' 1294 url: '/remito/mail-sin-valorizar'
1293 }, 1295 },
1294 options: { 1296 options: {
1295 idRemito: id 1297 idRemito: id
1296 } 1298 }
1297 } 1299 }
1298 ) 1300 )
1299 .then(function (res) { 1301 .then(function (res) {
1300 if (res === false) { 1302 if (res === false) {
1301 abrirModalMail(id); 1303 abrirModalMail(id);
1302 focaModalService.alert('Descarga o envíe su remito ' + 1304 focaModalService.alert('Descarga o envíe su remito ' +
1303 'antes de cerrar esta ventana'); 1305 'antes de cerrar esta ventana');
1304 } 1306 }
1305 }); 1307 });
1306 } 1308 }
1307 //recibo la propiedad por la cual quiero obtener el valor 1309 //recibo la propiedad por la cual quiero obtener el valor
1308 function getImporte(propiedad) { 1310 function getImporte(propiedad) {
1309 var importe = 0; 1311 var importe = 0;
1310 1312
1311 $scope.articulosFiltro().forEach(function (articulo) { 1313 $scope.articulosFiltro().forEach(function (articulo) {
1312 1314
1313 if (articulo[propiedad]) { 1315 if (articulo[propiedad]) {
1314 importe += articulo[propiedad] * articulo.cantidad; 1316 importe += articulo[propiedad] * articulo.cantidad;
1315 } 1317 }
1316 return; 1318 return;
1317 1319
1318 }); 1320 });
1319 1321
1320 return importe; 1322 return importe;
1321 } 1323 }
1322 } 1324 }
1323 ]); 1325 ]);
1324 1326