Commit b50408f1941aa7091a4356c0fb134c764f5ecc0c

Authored by Eric Fernandez

Merge branch 'master' into 'develop'

Master

See merge request !54
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 { 9 {
10 config(); 10 config();
11 11
12 function config() { 12 function config() {
13 $scope.botonera = crearRemitoService.getBotonera(); 13 $scope.botonera = crearRemitoService.getBotonera();
14 $scope.isNumber = angular.isNumber; 14 $scope.isNumber = angular.isNumber;
15 $scope.datepickerAbierto = false; 15 $scope.datepickerAbierto = false;
16 $scope.show = false; 16 $scope.show = false;
17 $scope.cargando = true; 17 $scope.cargando = true;
18 $scope.now = new Date(); 18 $scope.now = new Date();
19 $scope.puntoVenta = rellenar(0, 4); 19 $scope.puntoVenta = rellenar(0, 4);
20 $scope.comprobante = rellenar(0, 8); 20 $scope.comprobante = rellenar(0, 8);
21 $scope.dateOptions = { 21 $scope.dateOptions = {
22 maxDate: new Date(), 22 maxDate: new Date(),
23 minDate: new Date(2010, 0, 1) 23 minDate: new Date(2010, 0, 1)
24 }; 24 };
25 25
26 var monedaPorDefecto; 26 var monedaPorDefecto;
27 //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' 27 //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]'
28 crearRemitoService.getCotizacionByIdMoneda(1).then(function(res) { 28 crearRemitoService.getCotizacionByIdMoneda(1).then(function(res) {
29 monedaPorDefecto = res.data[0]; 29 monedaPorDefecto = res.data[0];
30 30
31 $scope.remito.cotizacion = Object.assign( 31 $scope.remito.cotizacion = Object.assign(
32 {moneda: monedaPorDefecto}, monedaPorDefecto.cotizaciones[0] 32 {moneda: monedaPorDefecto}, monedaPorDefecto.cotizaciones[0]
33 ); 33 );
34 $scope.inicial.cotizacion = $scope.remito.cotizacion; 34 $scope.inicial.cotizacion = $scope.remito.cotizacion;
35 $scope.cotizacionPorDefecto = angular.copy($scope.remito.cotizacion); 35 $scope.cotizacionPorDefecto = angular.copy($scope.remito.cotizacion);
36 }); 36 });
37 37
38 //SETEO BOTONERA LATERAL 38 //SETEO BOTONERA LATERAL
39 $timeout(function() { 39 $timeout(function() {
40 focaBotoneraLateralService.showSalir(false); 40 focaBotoneraLateralService.showSalir(false);
41 focaBotoneraLateralService.showPausar(true); 41 focaBotoneraLateralService.showPausar(true);
42 focaBotoneraLateralService.showGuardar(true, $scope.crearRemito); 42 focaBotoneraLateralService.showGuardar(true, $scope.crearRemito);
43 focaBotoneraLateralService.addCustomButton('Salir', salir); 43 focaBotoneraLateralService.addCustomButton('Salir', salir);
44 }); 44 });
45 45
46 init(); 46 init();
47 $timeout(function() {getLSRemito();}); 47 $timeout(function() {getLSRemito();});
48 } 48 }
49 49
50 function init() { 50 function init() {
51 $scope.$broadcast('cleanCabecera'); 51 $scope.$broadcast('cleanCabecera');
52 52
53 $scope.remito = { 53 $scope.remito = {
54 id: 0, 54 id: 0,
55 estado: 0, 55 estado: 0,
56 vendedor: {}, 56 vendedor: {},
57 cliente: {}, 57 cliente: {},
58 proveedor: {}, 58 proveedor: {},
59 domicilio: {dom: ''}, 59 domicilio: {dom: ''},
60 moneda: {}, 60 moneda: {},
61 cotizacion: $scope.cotizacionPorDefecto || {}, 61 cotizacion: $scope.cotizacionPorDefecto || {},
62 articulosRemito: [] 62 articulosRemito: []
63 }; 63 };
64 64
65 $scope.notaPedido = { 65 $scope.notaPedido = {
66 id: 0 66 id: 0
67 }; 67 };
68 68
69 $scope.remito.articulosRemito = []; 69 $scope.remito.articulosRemito = [];
70 $scope.idLista = undefined; 70 $scope.idLista = undefined;
71 71
72 crearRemitoService.getNumeroRemito().then( 72 crearRemitoService.getNumeroRemito().then(
73 function(res) { 73 function(res) {
74 $scope.puntoVenta = rellenar(res.data.sucursal, 4); 74 $scope.puntoVenta = rellenar(res.data.sucursal, 4);
75 $scope.comprobante = rellenar(res.data.numeroRemito, 8); 75 $scope.comprobante = rellenar(res.data.numeroRemito, 8);
76 }, 76 },
77 function(err) { 77 function(err) {
78 focaModalService.alert('La terminal no esta configurada correctamente'); 78 focaModalService.alert('La terminal no esta configurada correctamente');
79 console.info(err); 79 console.info(err);
80 } 80 }
81 ); 81 );
82 82
83 $scope.inicial = angular.copy($scope.remito); 83 $scope.inicial = angular.copy($scope.remito);
84 } 84 }
85 85
86 $scope.$watch('remito', function(newValue) { 86 $scope.$watch('remito', function(newValue) {
87 focaBotoneraLateralService.setPausarData({ 87 focaBotoneraLateralService.setPausarData({
88 label: 'remito', 88 label: 'remito',
89 val: newValue 89 val: newValue
90 }); 90 });
91 }, true); 91 }, true);
92 92
93 $scope.seleccionarNotaPedido = function() { 93 $scope.seleccionarNotaPedido = function() {
94 if(varlidarRemitoFacturado()) { 94 if (varlidarRemitoFacturado()) {
95 var modalInstance = $uibModal.open( 95 var modalInstance = $uibModal.open(
96 { 96 {
97 ariaLabelledBy: 'Busqueda de Nota de Pedido', 97 ariaLabelledBy: 'Busqueda de Nota de Pedido',
98 templateUrl: 'foca-modal-nota-pedido.html', 98 templateUrl: 'foca-modal-nota-pedido.html',
99 controller: 'focaModalNotaPedidoController', 99 controller: 'focaModalNotaPedidoController',
100 size: 'lg', 100 size: 'lg',
101 resolve: { 101 resolve: {
102 usadoPor: function() { return 'remito'; }, 102 usadoPor: function() { return 'remito'; },
103 idVendedor: function() { return null; } 103 idVendedor: function() { return null; }
104 } 104 }
105 } 105 }
106 ); 106 );
107 modalInstance.result.then( 107 modalInstance.result.then(
108 function(notaPedido) { 108 function(notaPedido) {
109 //añado cabeceras 109 //añado cabeceras
110 $scope.notaPedido.id = notaPedido.id; 110 $scope.notaPedido.id = notaPedido.id;
111 $scope.$broadcast('removeCabecera', 'Bomba:'); 111 $scope.$broadcast('removeCabecera', 'Bomba:');
112 $scope.$broadcast('removeCabecera', 'Kilometros:'); 112 $scope.$broadcast('removeCabecera', 'Kilometros:');
113 var cabeceras = [ 113 var cabeceras = [
114 { 114 {
115 label: 'Moneda:', 115 label: 'Moneda:',
116 valor: notaPedido.cotizacion.moneda.DETALLE 116 valor: notaPedido.cotizacion.moneda.DETALLE
117 }, 117 },
118 { 118 {
119 label: 'Fecha cotizacion:', 119 label: 'Fecha cotizacion:',
120 valor: $filter('date')(notaPedido.cotizacion.FECHA, 120 valor: $filter('date')(notaPedido.cotizacion.FECHA,
121 'dd/MM/yyyy') 121 'dd/MM/yyyy')
122 }, 122 },
123 { 123 {
124 label: 'Cotizacion:', 124 label: 'Cotizacion:',
125 valor: $filter('number')(notaPedido.cotizacion.VENDEDOR, 125 valor: $filter('number')(notaPedido.cotizacion.VENDEDOR,
126 '2') 126 '2')
127 }, 127 },
128 { 128 {
129 label: 'Cliente:', 129 label: 'Cliente:',
130 valor: $filter('rellenarDigitos')(notaPedido.cliente.COD, 3) + 130 valor: $filter('rellenarDigitos')(notaPedido.cliente.COD, 3) +
131 ' - ' + notaPedido.cliente.NOM 131 ' - ' + notaPedido.cliente.NOM
132 }, 132 },
133 { 133 {
134 label: 'Domicilio:', 134 label: 'Domicilio:',
135 valor: notaPedido.domicilioStamp 135 valor: notaPedido.domicilioStamp
136 }, 136 },
137 { 137 {
138 label: 'Vendedor:', 138 label: 'Vendedor:',
139 valor: $filter('rellenarDigitos')( 139 valor: $filter('rellenarDigitos')(
140 notaPedido.vendedor.NUM, 3 140 notaPedido.vendedor.NUM, 3
141 ) + ' - ' + notaPedido.vendedor.NOM 141 ) + ' - ' + notaPedido.vendedor.NOM
142 }, 142 },
143 { 143 {
144 label: 'Proveedor:', 144 label: 'Proveedor:',
145 valor: $filter('rellenarDigitos') 145 valor: $filter('rellenarDigitos')
146 (notaPedido.proveedor.COD, 5) + ' - ' + 146 (notaPedido.proveedor.COD, 5) + ' - ' +
147 notaPedido.proveedor.NOM 147 notaPedido.proveedor.NOM
148 }, 148 },
149 { 149 {
150 label: 'Precio condicion:', 150 label: 'Precio condicion:',
151 valor: valorPrecioCondicion() + ' ' + 151 valor: valorPrecioCondicion() + ' ' +
152 remitoBusinessService 152 remitoBusinessService
153 .plazoToString(notaPedido.notaPedidoPlazo) 153 .plazoToString(notaPedido.notaPedidoPlazo)
154 }, 154 },
155 { 155 {
156 label: 'Flete:', 156 label: 'Flete:',
157 valor: notaPedido.fob === 1 ? 'FOB' : ( 157 valor: notaPedido.fob === 1 ? 'FOB' : (
158 notaPedido.flete === 1 ? 'Si' : 'No') 158 notaPedido.flete === 1 ? 'Si' : 'No')
159 } 159 }
160 ]; 160 ];
161 161
162 if (notaPedido.observaciones) { 162 if (notaPedido.observaciones) {
163 cabeceras.push({ 163 cabeceras.push({
164 label: 'Observaciones:', 164 label: 'Observaciones:',
165 valor: notaPedido.observaciones 165 valor: notaPedido.observaciones
166 }); 166 });
167 } 167 }
168 168
169 function valorPrecioCondicion() { 169 function valorPrecioCondicion() {
170 if (notaPedido.idPrecioCondicion > 0) { 170 if (notaPedido.idPrecioCondicion > 0) {
171 return notaPedido.precioCondicion.nombre; 171 return notaPedido.precioCondicion.nombre;
172 } else { 172 } else {
173 return 'Ingreso Manual'; 173 return 'Ingreso Manual';
174 } 174 }
175 } 175 }
176 176
177 if (notaPedido.flete === 1) { 177 if (notaPedido.flete === 1) {
178 var cabeceraBomba = { 178 var cabeceraBomba = {
179 label: 'Bomba:', 179 label: 'Bomba:',
180 valor: notaPedido.bomba === 1 ? 'Si' : 'No' 180 valor: notaPedido.bomba === 1 ? 'Si' : 'No'
181 }; 181 };
182 if (notaPedido.kilometros) { 182 if (notaPedido.kilometros) {
183 var cabeceraKilometros = { 183 var cabeceraKilometros = {
184 label: 'Kilometros:', 184 label: 'Kilometros:',
185 valor: notaPedido.kilometros 185 valor: notaPedido.kilometros
186 }; 186 };
187 cabeceras.push(cabeceraKilometros); 187 cabeceras.push(cabeceraKilometros);
188 } 188 }
189 cabeceras.push(cabeceraBomba); 189 cabeceras.push(cabeceraBomba);
190 } 190 }
191 191
192 delete notaPedido.id; 192 delete notaPedido.id;
193 $scope.remito = notaPedido; 193 $scope.remito = notaPedido;
194 $scope.remito.id = 0; 194 $scope.remito.id = 0;
195 $scope.remito.remitoPlazo = notaPedido.notaPedidoPlazo; 195 $scope.remito.remitoPlazo = notaPedido.notaPedidoPlazo;
196 196
197 for(var i = notaPedido.articulosNotaPedido.length - 1; i >= 0; i--) { 197 for(var i = notaPedido.articulosNotaPedido.length - 1; i >= 0; i--) {
198 notaPedido.articulosNotaPedido[i].id = 0; 198 notaPedido.articulosNotaPedido[i].id = 0;
199 } 199 }
200 200
201 $scope.remito.articulosRemito = notaPedido.articulosNotaPedido; 201 $scope.remito.articulosRemito = notaPedido.articulosNotaPedido;
202 remitoBusinessService.calcularArticulos($scope.remito.articulosRemito, 202 remitoBusinessService.calcularArticulos($scope.remito.articulosRemito,
203 notaPedido.cotizacion.VENDEDOR); 203 notaPedido.cotizacion.VENDEDOR);
204 204
205 if(notaPedido.idPrecioCondicion > 0) { 205 if (notaPedido.idPrecioCondicion > 0) {
206 $scope.idLista = notaPedido.precioCondicion.idListaPrecio; 206 $scope.idLista = notaPedido.precioCondicion.idListaPrecio;
207 }else { 207 }else {
208 $scope.idLista = -1; 208 $scope.idLista = -1;
209 } 209 }
210 210
211 enableObservaciones(notaPedido.observaciones ? true : false); 211 enableObservaciones(notaPedido.observaciones ? true : false);
212 addArrayCabecera(cabeceras); 212 addArrayCabecera(cabeceras);
213 213
214 }, function() { 214 }, function() {
215 // funcion ejecutada cuando se cancela el modal 215 // funcion ejecutada cuando se cancela el modal
216 } 216 }
217 ); 217 );
218 } 218 }
219 }; 219 };
220 220
221 $scope.seleccionarRemito = function() { 221 $scope.seleccionarRemito = function() {
222 var modalInstance = $uibModal.open( 222 var modalInstance = $uibModal.open(
223 { 223 {
224 ariaLabelledBy: 'Busqueda de Remito', 224 ariaLabelledBy: 'Busqueda de Remito',
225 templateUrl: 'foca-modal-remito.html', 225 templateUrl: 'foca-modal-remito.html',
226 controller: 'focaModalRemitoController', 226 controller: 'focaModalRemitoController',
227 size: 'lg', 227 size: 'lg',
228 resolve: {usadoPor: function() {return 'remito';}} 228 resolve: {usadoPor: function() {return 'remito';}}
229 } 229 }
230 ); 230 );
231 modalInstance.result.then( 231 modalInstance.result.then(
232 setearRemito, function() { 232 setearRemito, function() {
233 // funcion ejecutada cuando se cancela el modal 233 // funcion ejecutada cuando se cancela el modal
234 } 234 }
235 ); 235 );
236 }; 236 };
237 237
238 //validacion por domicilio y por plazo pago 238 //validacion por domicilio y por plazo pago
239 $scope.crearRemito = function() { 239 $scope.crearRemito = function() {
240 if (!$scope.remito.vendedor.NUM) { 240 if (!$scope.remito.vendedor.NUM) {
241 focaModalService.alert('Ingrese Vendedor'); 241 focaModalService.alert('Ingrese Vendedor');
242 return; 242 return;
243 } else if (!$scope.remito.cliente.COD) { 243 } else if (!$scope.remito.cliente.COD) {
244 focaModalService.alert('Ingrese Cliente'); 244 focaModalService.alert('Ingrese Cliente');
245 return; 245 return;
246 } else if (!$scope.remito.proveedor) { 246 } else if (!$scope.remito.proveedor) {
247 focaModalService.alert('Ingrese Proveedor'); 247 focaModalService.alert('Ingrese Proveedor');
248 return; 248 return;
249 } else if (!$scope.remito.cotizacion.moneda.id && 249 } else if (!$scope.remito.cotizacion.moneda.id &&
250 !$scope.remito.cotizacion.moneda.ID) 250 !$scope.remito.cotizacion.moneda.ID)
251 { 251 {
252 focaModalService.alert('Ingrese Moneda'); 252 focaModalService.alert('Ingrese Moneda');
253 return; 253 return;
254 } else if (!$scope.remito.cotizacion.ID) { 254 } else if (!$scope.remito.cotizacion.ID) {
255 focaModalService.alert('Ingrese Cotización'); 255 focaModalService.alert('Ingrese Cotización');
256 return; 256 return;
257 } else if ( 257 } else if (
258 $scope.remito.flete === undefined || $scope.remito.flete === null) 258 $scope.remito.flete === undefined || $scope.remito.flete === null)
259 { 259 {
260 focaModalService.alert('Ingrese Flete'); 260 focaModalService.alert('Ingrese Flete');
261 return; 261 return;
262 } else if ($scope.remito.articulosRemito.length === 0) { 262 } else if ($scope.remito.articulosRemito.length === 0) {
263 focaModalService.alert('Debe cargar al menos un articulo'); 263 focaModalService.alert('Debe cargar al menos un articulo');
264 return; 264 return;
265 } 265 }
266 focaBotoneraLateralService.startGuardar(); 266 focaBotoneraLateralService.startGuardar();
267 $scope.saveLoading = true; 267 $scope.saveLoading = true;
268 var save = { 268 var save = {
269 remito: { 269 remito: {
270 id: $scope.remito.id, 270 id: $scope.remito.id,
271 fechaRemito: $scope.now.toISOString().slice(0, 19).replace('T', ' '), 271 fechaRemito: $scope.now.toISOString().slice(0, 19).replace('T', ' '),
272 idCliente: $scope.remito.cliente.COD, 272 idCliente: $scope.remito.cliente.COD,
273 nombreCliente: $scope.remito.cliente.NOM, 273 nombreCliente: $scope.remito.cliente.NOM,
274 cuitCliente: $scope.remito.cliente.CUIT, 274 cuitCliente: $scope.remito.cliente.CUIT,
275 responsabilidadIvaCliente: 0,//TODO, 275 responsabilidadIvaCliente: 0,//TODO,
276 descuento: 0,//TODO, 276 descuento: 0,//TODO,
277 importeNeto: 0,//TODO 277 importeNeto: 0,//TODO
278 importeExento: 0,//TODO 278 importeExento: 0,//TODO
279 importeIva: 0,//TODO 279 importeIva: 0,//TODO
280 importeIvaServicios: 0,//TODO 280 importeIvaServicios: 0,//TODO
281 importeImpuestoInterno: 0,//TODO 281 importeImpuestoInterno: 0,//TODO
282 importeImpuestoInterno1: 0,//TODO 282 importeImpuestoInterno1: 0,//TODO
283 importeImpuestoInterno2: 0,//TODO 283 importeImpuestoInterno2: 0,//TODO
284 percepcion: 0,//TODO 284 percepcion: 0,//TODO
285 percepcionIva: 0,//TODO 285 percepcionIva: 0,//TODO
286 redondeo: 0,//TODO 286 redondeo: 0,//TODO
287 total: $scope.getTotal() * $scope.remito.cotizacion.VENDEDOR, 287 total: $scope.getTotal() * $scope.remito.cotizacion.VENDEDOR,
288 numeroNotaPedido: $scope.remito.numeroNotaPedido, 288 numeroNotaPedido: $scope.remito.numeroNotaPedido,
289 anulado: false, 289 anulado: false,
290 planilla: 0,//TODO 290 planilla: 0,//TODO
291 lugar: 0,//TODO 291 lugar: 0,//TODO
292 cuentaMadre: 0,// 292 cuentaMadre: 0,//
293 cuentaContable: 0,//TODO 293 cuentaContable: 0,//TODO
294 asiento: 0,//TODO 294 asiento: 0,//TODO
295 e_hd: '',//TODO 295 e_hd: '',//TODO
296 c_hd: '', 296 c_hd: '',
297 numeroLiquidoProducto: 0,//TODO 297 numeroLiquidoProducto: 0,//TODO
298 idVendedor: $scope.remito.idVendedor, 298 idVendedor: $scope.remito.idVendedor,
299 idProveedor: $scope.remito.idProveedor, 299 idProveedor: $scope.remito.idProveedor,
300 idDomicilio: $scope.remito.idDomicilio, 300 idDomicilio: $scope.remito.idDomicilio,
301 idCotizacion: $scope.remito.cotizacion.ID, 301 idCotizacion: $scope.remito.cotizacion.ID,
302 idPrecioCondicion: $scope.remito.idPrecioCondicion, 302 idPrecioCondicion: $scope.remito.idPrecioCondicion,
303 flete: $scope.remito.flete, 303 flete: $scope.remito.flete,
304 fob: $scope.remito.fob, 304 fob: $scope.remito.fob,
305 bomba: $scope.remito.bomba, 305 bomba: $scope.remito.bomba,
306 kilometros: $scope.remito.kilometros, 306 kilometros: $scope.remito.kilometros,
307 domicilioStamp: $scope.remito.domicilioStamp, 307 domicilioStamp: $scope.remito.domicilioStamp,
308 estado: 0,//TODO 308 estado: 0,//TODO
309 destinoVenta: 0,//TODO 309 destinoVenta: 0,//TODO
310 operacionTipo: 0//TODO 310 operacionTipo: 0//TODO
311 }, 311 },
312 notaPedido: $scope.notaPedido 312 notaPedido: $scope.notaPedido
313 }; 313 };
314 314
315 crearRemitoService.crearRemito(save).then( 315 crearRemitoService.crearRemito(save).then(
316 function(data) { 316 function(data) {
317 remitoBusinessService.addArticulos($scope.remito.articulosRemito, 317 remitoBusinessService.addArticulos($scope.remito.articulosRemito,
318 data.data.id, $scope.remito.cotizacion.COTIZACION); 318 data.data.id, $scope.remito.cotizacion.COTIZACION);
319 319
320 focaBotoneraLateralService.endGuardar(true); 320 focaBotoneraLateralService.endGuardar(true);
321 $scope.saveLoading = false; 321 $scope.saveLoading = false;
322 322
323 //TODO: updatear plazos 323 //TODO: updatear plazos
324 if($scope.remito.id === 0) { 324 if ($scope.remito.id === 0) {
325 var plazos = $scope.remito.remitoPlazo; 325 var plazos = $scope.remito.remitoPlazo;
326 326
327 for(var j = 0; j < plazos.length; j++) { 327 for(var j = 0; j < plazos.length; j++) {
328 var json = { 328 var json = {
329 idRemito: $scope.remito.id, 329 idRemito: $scope.remito.id,
330 dias: plazos[j].dias 330 dias: plazos[j].dias
331 }; 331 };
332 crearRemitoService.crearPlazosParaRemito(json); 332 crearRemitoService.crearPlazosParaRemito(json);
333 } 333 }
334 } 334 }
335 335 abrirModalMail(data.data.id, $scope.remito.cliente, $filter('comprobante')([
336 $uibModal.open({ 336 data.data.sucursal,
337 templateUrl: 'remito-comprobante.html', 337 data.data.numero
338 controller: 'focaRemitoComprobanteController', 338 ]));
339 resolve: {
340 parametros: {
341 idRemito: data.data.id
342 }
343 }
344 });
345 339
346 init(); 340 init();
347 341
348 }, function(error) { 342 }, function(error) {
349 focaModalService.alert('Hubo un error al crear el remito'); 343 focaModalService.alert('Hubo un error al crear el remito');
350 focaBotoneraLateralService.endGuardar(); 344 focaBotoneraLateralService.endGuardar();
351 $scope.saveLoading = false; 345 $scope.saveLoading = false;
352 console.info(error); 346 console.info(error);
353 } 347 }
354 ); 348 );
355 }; 349 };
356 350
357 $scope.seleccionarProductos = function() { 351 $scope.seleccionarProductos = function() {
358 if($scope.idLista === undefined) { 352 if ($scope.idLista === undefined) {
359 focaModalService.alert( 353 focaModalService.alert(
360 'Primero seleccione una lista de precio y condicion'); 354 'Primero seleccione una lista de precio y condicion');
361 return; 355 return;
362 } 356 }
363 var modalInstance = $uibModal.open( 357 var modalInstance = $uibModal.open(
364 { 358 {
365 ariaLabelledBy: 'Busqueda de Productos', 359 ariaLabelledBy: 'Busqueda de Productos',
366 templateUrl: 'modal-busqueda-productos.html', 360 templateUrl: 'modal-busqueda-productos.html',
367 controller: 'modalBusquedaProductosCtrl', 361 controller: 'modalBusquedaProductosCtrl',
368 resolve: { 362 resolve: {
369 parametroProducto: { 363 parametroProducto: {
370 idLista: $scope.idLista, 364 idLista: $scope.idLista,
371 cotizacion: $scope.remito.cotizacion.COTIZACION, 365 cotizacion: $scope.remito.cotizacion.COTIZACION,
372 simbolo: $scope.remito.cotizacion.moneda.simbolo 366 simbolo: $scope.remito.cotizacion.moneda.simbolo
373 } 367 }
374 }, 368 },
375 size: 'lg' 369 size: 'lg'
376 } 370 }
377 ); 371 );
378 modalInstance.result.then( 372 modalInstance.result.then(
379 function(producto) { 373 function(producto) {
380 var newArt = 374 var newArt =
381 { 375 {
382 id: 0, 376 id: 0,
383 codigo: producto.codigo, 377 codigo: producto.codigo,
384 sector: producto.sector, 378 sector: producto.sector,
385 sectorCodigo: producto.sector + '-' + producto.codigo, 379 sectorCodigo: producto.sector + '-' + producto.codigo,
386 descripcion: producto.descripcion, 380 descripcion: producto.descripcion,
387 item: $scope.remito.articulosRemito.length + 1, 381 item: $scope.remito.articulosRemito.length + 1,
388 nombre: producto.descripcion, 382 nombre: producto.descripcion,
389 precio: parseFloat(producto.precio.toFixed(4)), 383 precio: parseFloat(producto.precio.toFixed(4)),
390 costoUnitario: producto.costo, 384 costoUnitario: producto.costo,
391 editCantidad: false, 385 editCantidad: false,
392 editPrecio: false, 386 editPrecio: false,
393 rubro: producto.CodRub, 387 rubro: producto.CodRub,
394 exentoUnitario: producto.precio, 388 exentoUnitario: producto.precio,
395 ivaUnitario: producto.IMPIVA, 389 ivaUnitario: producto.IMPIVA,
396 impuestoInternoUnitario: producto.ImpInt, 390 impuestoInternoUnitario: producto.ImpInt,
397 impuestoInterno1Unitario: producto.ImpInt2, 391 impuestoInterno1Unitario: producto.ImpInt2,
398 impuestoInterno2Unitario: producto.ImpInt3, 392 impuestoInterno2Unitario: producto.ImpInt3,
399 precioLista: producto.precio, 393 precioLista: producto.precio,
400 combustible: 1, 394 combustible: 1,
401 facturado: 0 395 facturado: 0
402 }; 396 };
403 $scope.articuloACargar = newArt; 397 $scope.articuloACargar = newArt;
404 $scope.cargando = false; 398 $scope.cargando = false;
405 }, function() { 399 }, function() {
406 // funcion ejecutada cuando se cancela el modal 400 // funcion ejecutada cuando se cancela el modal
407 } 401 }
408 ); 402 );
409 }; 403 };
410 404
411 $scope.seleccionarPuntosDeDescarga = function() { 405 $scope.seleccionarPuntosDeDescarga = function() {
412 if(!$scope.remito.cliente.COD || !$scope.remito.domicilio.id) { 406 if (!$scope.remito.cliente.COD || !$scope.remito.domicilio.id) {
413 focaModalService.alert('Primero seleccione un cliente y un domicilio'); 407 focaModalService.alert('Primero seleccione un cliente y un domicilio');
414 return; 408 return;
415 }else { 409 }else {
416 var modalInstance = $uibModal.open( 410 var modalInstance = $uibModal.open(
417 { 411 {
418 ariaLabelledBy: 'Búsqueda de Puntos de descarga', 412 ariaLabelledBy: 'Búsqueda de Puntos de descarga',
419 templateUrl: 'modal-punto-descarga.html', 413 templateUrl: 'modal-punto-descarga.html',
420 controller: 'focaModalPuntoDescargaController', 414 controller: 'focaModalPuntoDescargaController',
421 size: 'lg', 415 size: 'lg',
422 resolve: { 416 resolve: {
423 filters: { 417 filters: {
424 idDomicilio: $scope.remito.domicilio.id, 418 idDomicilio: $scope.remito.domicilio.id,
425 idCliente: $scope.remito.cliente.COD, 419 idCliente: $scope.remito.cliente.COD,
426 articulos: $scope.remito.articulosRemito, 420 articulos: $scope.remito.articulosRemito,
427 puntosDescarga: $scope.remito.domicilio.puntosDescarga 421 puntosDescarga: $scope.remito.domicilio.puntosDescarga
428 } 422 }
429 } 423 }
430 } 424 }
431 ); 425 );
432 modalInstance.result.then( 426 modalInstance.result.then(
433 function(puntosDescarga) { 427 function(puntosDescarga) {
434 $scope.remito.puntosDescarga = puntosDescarga; 428 $scope.remito.puntosDescarga = puntosDescarga;
435 429
436 //AGREGO PUNTOS DE DESCARGA A CABECERA 430 //AGREGO PUNTOS DE DESCARGA A CABECERA
437 var puntosStamp = ''; 431 var puntosStamp = '';
438 puntosDescarga.forEach(function(punto, idx, arr) { 432 puntosDescarga.forEach(function(punto, idx, arr) {
439 puntosStamp += punto.descripcion; 433 puntosStamp += punto.descripcion;
440 if((idx + 1) !== arr.length) puntosStamp += ', '; 434 if ((idx + 1) !== arr.length) puntosStamp += ', ';
441 }); 435 });
442 436
443 $scope.$broadcast('addCabecera', { 437 $scope.$broadcast('addCabecera', {
444 label: 'Puntos de descarga:', 438 label: 'Puntos de descarga:',
445 valor: puntosStamp 439 valor: puntosStamp
446 }); 440 });
447 }, function() { 441 }, function() {
448 $scope.abrirModalDomicilios($scope.cliente); 442 $scope.abrirModalDomicilios($scope.cliente);
449 } 443 }
450 ); 444 );
451 } 445 }
452 }; 446 };
453 447
454 $scope.seleccionarVendedor = function(callback, ocultarVendedor) { 448 $scope.seleccionarVendedor = function(callback, ocultarVendedor) {
455 if (ocultarVendedor) { 449 if (ocultarVendedor) {
456 callback(); 450 callback();
457 return; 451 return;
458 } 452 }
459 453
460 if(varlidarRemitoFacturado()) { 454 if (varlidarRemitoFacturado()) {
461 var parametrosModal = { 455 var parametrosModal = {
462 titulo: 'Búsqueda vendedores', 456 titulo: 'Búsqueda vendedores',
463 query: '/vendedor', 457 query: '/vendedor',
464 columnas: [ 458 columnas: [
465 { 459 {
466 propiedad: 'NUM', 460 propiedad: 'NUM',
467 nombre: 'Código', 461 nombre: 'Código',
468 filtro: { 462 filtro: {
469 nombre: 'rellenarDigitos', 463 nombre: 'rellenarDigitos',
470 parametro: 3 464 parametro: 3
471 } 465 }
472 }, 466 },
473 { 467 {
474 propiedad: 'NOM', 468 propiedad: 'NOM',
475 nombre: 'Nombre' 469 nombre: 'Nombre'
476 } 470 }
477 ], 471 ],
478 size: 'md' 472 size: 'md'
479 }; 473 };
480 focaModalService.modal(parametrosModal).then( 474 focaModalService.modal(parametrosModal).then(
481 function(vendedor) { 475 function(vendedor) {
482 $scope.$broadcast('addCabecera',{ 476 $scope.$broadcast('addCabecera',{
483 label: 'Vendedor:', 477 label: 'Vendedor:',
484 valor: $filter('rellenarDigitos')(vendedor.NUM, 3) + ' - ' + 478 valor: $filter('rellenarDigitos')(vendedor.NUM, 3) + ' - ' +
485 vendedor.NOM 479 vendedor.NOM
486 }); 480 });
487 $scope.remito.idVendedor = vendedor.id; 481 $scope.remito.idVendedor = vendedor.id;
488 $scope.remito.vendedor = vendedor; 482 $scope.remito.vendedor = vendedor;
489 deleteCliente(); 483 deleteCliente();
490 callback(); 484 callback();
491 }, function() { 485 }, function() {
492 486
493 } 487 }
494 ); 488 );
495 } 489 }
496 }; 490 };
497 491
498 $scope.seleccionarCliente = function(ocultarVendedor) { 492 $scope.seleccionarCliente = function(ocultarVendedor) {
499 493
500 $scope.seleccionarVendedor(function() { 494 $scope.seleccionarVendedor(function() {
501 if (varlidarRemitoFacturado()) { 495 if (varlidarRemitoFacturado()) {
502 var modalInstance = $uibModal.open( 496 var modalInstance = $uibModal.open(
503 { 497 {
504 ariaLabelledBy: 'Busqueda de Cliente', 498 ariaLabelledBy: 'Busqueda de Cliente',
505 templateUrl: 'foca-busqueda-cliente-modal.html', 499 templateUrl: 'foca-busqueda-cliente-modal.html',
506 controller: 'focaBusquedaClienteModalController', 500 controller: 'focaBusquedaClienteModalController',
507 resolve: { 501 resolve: {
508 vendedor: function() { return $scope.remito.vendedor; }, 502 vendedor: function() { return $scope.remito.vendedor; },
509 cobrador: function() { return null; } 503 cobrador: function() { return null; }
510 }, 504 },
511 size: 'lg' 505 size: 'lg'
512 } 506 }
513 ); 507 );
514 modalInstance.result.then( 508 modalInstance.result.then(
515 function(cliente) { 509 function(cliente) {
516 $scope.abrirModalDomicilios(cliente); 510 $scope.abrirModalDomicilios(cliente);
517 $scope.cliente = cliente; 511 $scope.cliente = cliente;
518 }, function() { 512 }, function() {
519 $scope.seleccionarCliente(); 513 $scope.seleccionarCliente();
520 } 514 }
521 ); 515 );
522 } 516 }
523 }, ocultarVendedor); 517 }, ocultarVendedor);
524 }; 518 };
525 519
526 $scope.seleccionarProveedor = function(callback) { 520 $scope.seleccionarProveedor = function(callback) {
527 if(varlidarRemitoFacturado()) { 521 if (varlidarRemitoFacturado()) {
528 var parametrosModal = { 522 var parametrosModal = {
529 titulo: 'Búsqueda de Proveedor', 523 titulo: 'Búsqueda de Proveedor',
530 query: '/proveedor', 524 query: '/proveedor',
531 columnas: [ 525 columnas: [
532 { 526 {
533 nombre: 'Código', 527 nombre: 'Código',
534 propiedad: 'COD', 528 propiedad: 'COD',
535 filtro: { 529 filtro: {
536 nombre: 'rellenarDigitos', 530 nombre: 'rellenarDigitos',
537 parametro: 5 531 parametro: 5
538 } 532 }
539 }, 533 },
540 { 534 {
541 nombre: 'Nombre', 535 nombre: 'Nombre',
542 propiedad: 'NOM' 536 propiedad: 'NOM'
543 }, 537 },
544 { 538 {
545 nombre: 'CUIT', 539 nombre: 'CUIT',
546 propiedad: 'CUIT' 540 propiedad: 'CUIT'
547 } 541 }
548 ], 542 ],
549 tipo: 'POST', 543 tipo: 'POST',
550 json: {razonCuitCod: ''} 544 json: {razonCuitCod: ''}
551 }; 545 };
552 focaModalService.modal(parametrosModal).then( 546 focaModalService.modal(parametrosModal).then(
553 function(proveedor) { 547 function(proveedor) {
554 $scope.remito.proveedor = proveedor; 548 $scope.remito.proveedor = proveedor;
555 $scope.remito.idProveedor = proveedor.COD; 549 $scope.remito.idProveedor = proveedor.COD;
556 550
557 $scope.$broadcast('addCabecera',{ 551 $scope.$broadcast('addCabecera',{
558 label: 'Proveedor:', 552 label: 'Proveedor:',
559 valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + 553 valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' +
560 proveedor.NOM 554 proveedor.NOM
561 }); 555 });
562 callback(); 556 callback();
563 }, function() { } 557 }, function() { }
564 ); 558 );
565 } 559 }
566 }; 560 };
567 561
568 $scope.abrirModalDomicilios = function(cliente) { 562 $scope.abrirModalDomicilios = function(cliente) {
569 var modalInstanceDomicilio = $uibModal.open( 563 var modalInstanceDomicilio = $uibModal.open(
570 { 564 {
571 ariaLabelledBy: 'Busqueda de Domicilios', 565 ariaLabelledBy: 'Busqueda de Domicilios',
572 templateUrl: 'modal-domicilio.html', 566 templateUrl: 'modal-domicilio.html',
573 controller: 'focaModalDomicilioController', 567 controller: 'focaModalDomicilioController',
574 size: 'lg', 568 size: 'lg',
575 resolve: { 569 resolve: {
576 idCliente: function() { return cliente.cod; }, 570 idCliente: function() { return cliente.cod; },
577 esNuevo: function() { return cliente.esNuevo; } 571 esNuevo: function() { return cliente.esNuevo; }
578 } 572 }
579 } 573 }
580 ); 574 );
581 modalInstanceDomicilio.result.then( 575 modalInstanceDomicilio.result.then(
582 function(domicilio) { 576 function(domicilio) {
583 $scope.remito.domicilio = domicilio; 577 $scope.remito.domicilio = domicilio;
584 $scope.remito.cliente = { 578 $scope.remito.cliente = {
585 COD: cliente.cod, 579 COD: cliente.cod,
586 CUIT: cliente.cuit, 580 CUIT: cliente.cuit,
587 NOM: cliente.nom, 581 NOM: cliente.nom,
588 MAIL: cliente.mail, 582 MAIL: cliente.mail,
589 MOD: cliente.mod 583 MOD: cliente.mod
590 }; 584 };
591 585
592 586
593 var domicilioStamp = 587 var domicilioStamp =
594 domicilio.Calle + ' ' + domicilio.Numero + ', ' + 588 domicilio.Calle + ' ' + domicilio.Numero + ', ' +
595 domicilio.Localidad + ', ' + domicilio.Provincia; 589 domicilio.Localidad + ', ' + domicilio.Provincia;
596 $scope.remito.domicilioStamp = domicilioStamp; 590 $scope.remito.domicilioStamp = domicilioStamp;
597 591
598 $scope.$broadcast('addCabecera',{ 592 $scope.$broadcast('addCabecera',{
599 label: 'Cliente:', 593 label: 'Cliente:',
600 valor: $filter('rellenarDigitos')(cliente.cod, 3) + ' - ' + cliente.nom 594 valor: $filter('rellenarDigitos')(cliente.cod, 3) + ' - ' + cliente.nom
601 }); 595 });
602 $scope.$broadcast('addCabecera',{ 596 $scope.$broadcast('addCabecera',{
603 label: 'Domicilio:', 597 label: 'Domicilio:',
604 valor: domicilioStamp 598 valor: domicilioStamp
605 }); 599 });
606 600
607 if(domicilio.verPuntos) { 601 if (domicilio.verPuntos) {
608 delete $scope.remito.domicilio.verPuntos; 602 delete $scope.remito.domicilio.verPuntos;
609 $scope.seleccionarPuntosDeDescarga(); 603 $scope.seleccionarPuntosDeDescarga();
610 }else { 604 }else {
611 crearRemitoService 605 crearRemitoService
612 .getPuntosDescargaByClienDom(domicilio.id, cliente.cod) 606 .getPuntosDescargaByClienDom(domicilio.id, cliente.cod)
613 .then(function(res) { 607 .then(function(res) {
614 if(res.data.length) $scope.seleccionarPuntosDeDescarga(); 608 if (res.data.length) $scope.seleccionarPuntosDeDescarga();
615 }); 609 });
616 } 610 }
617 }, function() { 611 }, function() {
618 $scope.seleccionarCliente(true); 612 $scope.seleccionarCliente(true);
619 return; 613 return;
620 } 614 }
621 ); 615 );
622 }; 616 };
623 617
624 $scope.getTotal = function() { 618 $scope.getTotal = function() {
625 var total = 0; 619 var total = 0;
626 var arrayTempArticulos = $scope.remito.articulosRemito; 620 var arrayTempArticulos = $scope.remito.articulosRemito;
627 for(var i = 0; i < arrayTempArticulos.length; i++) { 621 for(var i = 0; i < arrayTempArticulos.length; i++) {
628 total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; 622 total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad;
629 } 623 }
630 return parseFloat(total.toFixed(2)); 624 return parseFloat(total.toFixed(2));
631 }; 625 };
632 626
633 $scope.getSubTotal = function() { 627 $scope.getSubTotal = function() {
634 if($scope.articuloACargar) { 628 if ($scope.articuloACargar) {
635 return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; 629 return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad;
636 } 630 }
637 }; 631 };
638 632
639 $scope.seleccionarPreciosYCondiciones = function() { 633 $scope.seleccionarPreciosYCondiciones = function() {
640 if (!$scope.remito.cliente.COD) { 634 if (!$scope.remito.cliente.COD) {
641 focaModalService.alert('Primero seleccione un cliente'); 635 focaModalService.alert('Primero seleccione un cliente');
642 return; 636 return;
643 } 637 }
644 if(varlidarRemitoFacturado()) { 638 if (varlidarRemitoFacturado()) {
645 var modalInstance = $uibModal.open( 639 var modalInstance = $uibModal.open(
646 { 640 {
647 ariaLabelledBy: 'Busqueda de Precio Condición', 641 ariaLabelledBy: 'Busqueda de Precio Condición',
648 templateUrl: 'modal-precio-condicion.html', 642 templateUrl: 'modal-precio-condicion.html',
649 controller: 'focaModalPrecioCondicionController', 643 controller: 'focaModalPrecioCondicionController',
650 size: 'lg', 644 size: 'lg',
651 resolve: { 645 resolve: {
652 idListaPrecio: function() { 646 idListaPrecio: function() {
653 return $scope.remito.cliente.MOD || null; 647 return $scope.remito.cliente.MOD || null;
654 } 648 }
655 } 649 }
656 } 650 }
657 ); 651 );
658 modalInstance.result.then( 652 modalInstance.result.then(
659 function(precioCondicion) { 653 function(precioCondicion) {
660 var cabecera = ''; 654 var cabecera = '';
661 var plazosConcat = ''; 655 var plazosConcat = '';
662 if(!Array.isArray(precioCondicion)) { 656 if (!Array.isArray(precioCondicion)) {
663 $scope.remito.idPrecioCondicion = precioCondicion.id; 657 $scope.remito.idPrecioCondicion = precioCondicion.id;
664 $scope.remito.remitoPlazo = precioCondicion.plazoPago; 658 $scope.remito.remitoPlazo = precioCondicion.plazoPago;
665 $scope.idLista = precioCondicion.idListaPrecio; 659 $scope.idLista = precioCondicion.idListaPrecio;
666 for(var i = 0; i < precioCondicion.plazoPago.length; i++) { 660 for(var i = 0; i < precioCondicion.plazoPago.length; i++) {
667 plazosConcat += precioCondicion.plazoPago[i].dias + ' '; 661 plazosConcat += precioCondicion.plazoPago[i].dias + ' ';
668 } 662 }
669 cabecera = $filter('rellenarDigitos')(precioCondicion.id, 4) + 663 cabecera = $filter('rellenarDigitos')(precioCondicion.id, 4) +
670 ' - ' + precioCondicion.nombre + ' ' + plazosConcat.trim(); 664 ' - ' + precioCondicion.nombre + ' ' + plazosConcat.trim();
671 }else { //Cuando se ingresan los plazos manualmente 665 }else { //Cuando se ingresan los plazos manualmente
672 $scope.remito.idPrecioCondicion = 0; 666 $scope.remito.idPrecioCondicion = 0;
673 //-1, el modal productos busca todos los productos 667 //-1, el modal productos busca todos los productos
674 $scope.idLista = -1; 668 $scope.idLista = -1;
675 $scope.remito.remitoPlazo = precioCondicion; 669 $scope.remito.remitoPlazo = precioCondicion;
676 for(var j = 0; j < precioCondicion.length; j++) { 670 for(var j = 0; j < precioCondicion.length; j++) {
677 plazosConcat += precioCondicion[j].dias + ' '; 671 plazosConcat += precioCondicion[j].dias + ' ';
678 } 672 }
679 cabecera = 'Ingreso manual ' + plazosConcat.trim(); 673 cabecera = 'Ingreso manual ' + plazosConcat.trim();
680 } 674 }
681 $scope.remito.articulosRemito = []; 675 $scope.remito.articulosRemito = [];
682 $scope.$broadcast('addCabecera',{ 676 $scope.$broadcast('addCabecera',{
683 label: 'Precios y condiciones:', 677 label: 'Precios y condiciones:',
684 valor: cabecera 678 valor: cabecera
685 }); 679 });
686 680
687 $scope.remito.precioCondicion = precioCondicion; 681 $scope.remito.precioCondicion = precioCondicion;
688 }, function() { 682 }, function() {
689 683
690 } 684 }
691 ); 685 );
692 } 686 }
693 }; 687 };
694 688
695 $scope.seleccionarTransportista = function() { 689 $scope.seleccionarTransportista = function() {
696 $scope.seleccionarProveedor(function() { 690 $scope.seleccionarProveedor(function() {
697 if (varlidarRemitoFacturado()) { 691 if (varlidarRemitoFacturado()) {
698 var modalInstance = $uibModal.open( 692 var modalInstance = $uibModal.open(
699 { 693 {
700 ariaLabelledBy: 'Busqueda de Flete', 694 ariaLabelledBy: 'Busqueda de Flete',
701 templateUrl: 'modal-flete.html', 695 templateUrl: 'modal-flete.html',
702 controller: 'focaModalFleteController', 696 controller: 'focaModalFleteController',
703 size: 'lg', 697 size: 'lg',
704 resolve: { 698 resolve: {
705 parametrosFlete: 699 parametrosFlete:
706 function() { 700 function() {
707 return { 701 return {
708 flete: $scope.remito.flete ? '1' : 702 flete: $scope.remito.flete ? '1' :
709 ($scope.remito.fob ? 'FOB' : 703 ($scope.remito.fob ? 'FOB' :
710 ($scope.remito.flete === undefined ? 704 ($scope.remito.flete === undefined ?
711 null : '0')), 705 null : '0')),
712 bomba: $scope.remito.bomba ? '1' : 706 bomba: $scope.remito.bomba ? '1' :
713 ($scope.remito.bomba === undefined ? 707 ($scope.remito.bomba === undefined ?
714 null : '0'), 708 null : '0'),
715 kilometros: $scope.remito.kilometros 709 kilometros: $scope.remito.kilometros
716 }; 710 };
717 } 711 }
718 } 712 }
719 } 713 }
720 ); 714 );
721 modalInstance.result.then( 715 modalInstance.result.then(
722 function(datos) { 716 function(datos) {
723 $scope.remito.flete = datos.flete; 717 $scope.remito.flete = datos.flete;
724 $scope.remito.fob = datos.FOB; 718 $scope.remito.fob = datos.FOB;
725 $scope.remito.bomba = datos.bomba; 719 $scope.remito.bomba = datos.bomba;
726 $scope.remito.kilometros = datos.kilometros; 720 $scope.remito.kilometros = datos.kilometros;
727 721
728 $scope.$broadcast('addCabecera',{ 722 $scope.$broadcast('addCabecera',{
729 label: 'Flete:', 723 label: 'Flete:',
730 valor: datos.flete ? 'Si' : ($scope.remito.fob ? 'FOB' : 'No') 724 valor: datos.flete ? 'Si' : ($scope.remito.fob ? 'FOB' : 'No')
731 }); 725 });
732 if (datos.flete) { 726 if (datos.flete) {
733 $scope.$broadcast('addCabecera',{ 727 $scope.$broadcast('addCabecera',{
734 label: 'Bomba:', 728 label: 'Bomba:',
735 valor: datos.bomba ? 'Si' : 'No' 729 valor: datos.bomba ? 'Si' : 'No'
736 }); 730 });
737 $scope.$broadcast('addCabecera',{ 731 $scope.$broadcast('addCabecera',{
738 label: 'Kilometros:', 732 label: 'Kilometros:',
739 valor: datos.kilometros 733 valor: datos.kilometros
740 }); 734 });
741 } else { 735 } else {
742 $scope.$broadcast('removeCabecera', 'Bomba:'); 736 $scope.$broadcast('removeCabecera', 'Bomba:');
743 $scope.$broadcast('removeCabecera', 'Kilometros:'); 737 $scope.$broadcast('removeCabecera', 'Kilometros:');
744 $scope.remito.fob = false; 738 $scope.remito.fob = false;
745 $scope.remito.bomba = false; 739 $scope.remito.bomba = false;
746 $scope.remito.kilometros = null; 740 $scope.remito.kilometros = null;
747 } 741 }
748 }, function() { 742 }, function() {
749 $scope.seleccionarTransportista(); 743 $scope.seleccionarTransportista();
750 } 744 }
751 ); 745 );
752 } 746 }
753 }); 747 });
754 }; 748 };
755 749
756 $scope.seleccionarMoneda = function() { 750 $scope.seleccionarMoneda = function() {
757 if(varlidarRemitoFacturado()) { 751 if (varlidarRemitoFacturado()) {
758 var parametrosModal = { 752 var parametrosModal = {
759 titulo: 'Búsqueda de monedas', 753 titulo: 'Búsqueda de monedas',
760 query: '/moneda', 754 query: '/moneda',
761 columnas: [ 755 columnas: [
762 { 756 {
763 propiedad: 'DETALLE', 757 propiedad: 'DETALLE',
764 nombre: 'Nombre' 758 nombre: 'Nombre'
765 }, 759 },
766 { 760 {
767 propiedad: 'SIMBOLO', 761 propiedad: 'SIMBOLO',
768 nombre: 'Símbolo' 762 nombre: 'Símbolo'
769 } 763 }
770 ], 764 ],
771 size: 'md' 765 size: 'md'
772 }; 766 };
773 focaModalService.modal(parametrosModal).then( 767 focaModalService.modal(parametrosModal).then(
774 function(moneda) { 768 function(moneda) {
775 $scope.abrirModalCotizacion(moneda); 769 $scope.abrirModalCotizacion(moneda);
776 }, function() { 770 }, function() {
777 771
778 } 772 }
779 ); 773 );
780 } 774 }
781 }; 775 };
782 776
783 $scope.seleccionarObservaciones = function() { 777 $scope.seleccionarObservaciones = function() {
784 focaModalService 778 focaModalService
785 .prompt({ 779 .prompt({
786 titulo: 'Observaciones', 780 titulo: 'Observaciones',
787 value: $scope.remito.observaciones, 781 value: $scope.remito.observaciones,
788 textarea: true, 782 textarea: true,
789 readonly: true 783 readonly: true
790 }) 784 })
791 .then(function(observaciones) { 785 .then(function(observaciones) {
792 $scope.remito.observaciones = observaciones; 786 $scope.remito.observaciones = observaciones;
793 }); 787 });
794 }; 788 };
795 789
796 $scope.abrirModalCotizacion = function(moneda) { 790 $scope.abrirModalCotizacion = function(moneda) {
797 var modalInstance = $uibModal.open( 791 var modalInstance = $uibModal.open(
798 { 792 {
799 ariaLabelledBy: 'Busqueda de Cotización', 793 ariaLabelledBy: 'Busqueda de Cotización',
800 templateUrl: 'modal-cotizacion.html', 794 templateUrl: 'modal-cotizacion.html',
801 controller: 'focaModalCotizacionController', 795 controller: 'focaModalCotizacionController',
802 size: 'lg', 796 size: 'lg',
803 resolve: {idMoneda: function() {return moneda.ID;}} 797 resolve: {idMoneda: function() {return moneda.ID;}}
804 } 798 }
805 ); 799 );
806 modalInstance.result.then( 800 modalInstance.result.then(
807 function(cotizacion) { 801 function(cotizacion) {
808 var articulosTablaTemp = $scope.remito.articulosRemito; 802 var articulosTablaTemp = $scope.remito.articulosRemito;
809 for(var i = 0; i < articulosTablaTemp.length; i++) { 803 for(var i = 0; i < articulosTablaTemp.length; i++) {
810 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * 804 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio *
811 $scope.remito.cotizacion.COTIZACION; 805 $scope.remito.cotizacion.COTIZACION;
812 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / 806 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio /
813 cotizacion.COTIZACION; 807 cotizacion.COTIZACION;
814 } 808 }
815 $scope.remito.articulosRemito = articulosTablaTemp; 809 $scope.remito.articulosRemito = articulosTablaTemp;
816 $scope.remito.cotizacion.moneda = moneda; 810 $scope.remito.cotizacion.moneda = moneda;
817 $scope.remito.cotizacion = cotizacion; 811 $scope.remito.cotizacion = cotizacion;
818 if(moneda.DETALLE === 'PESOS ARGENTINOS') { 812 if (moneda.DETALLE === 'PESOS ARGENTINOS') {
819 $scope.$broadcast('removeCabecera', 'Moneda:'); 813 $scope.$broadcast('removeCabecera', 'Moneda:');
820 $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); 814 $scope.$broadcast('removeCabecera', 'Fecha cotizacion:');
821 $scope.$broadcast('removeCabecera', 'Cotizacion:'); 815 $scope.$broadcast('removeCabecera', 'Cotizacion:');
822 }else { 816 }else {
823 $scope.$broadcast('addCabecera',{ 817 $scope.$broadcast('addCabecera',{
824 label: 'Moneda:', 818 label: 'Moneda:',
825 valor: moneda.DETALLE 819 valor: moneda.DETALLE
826 }); 820 });
827 $scope.$broadcast('addCabecera',{ 821 $scope.$broadcast('addCabecera',{
828 label: 'Fecha cotizacion:', 822 label: 'Fecha cotizacion:',
829 valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') 823 valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy')
830 }); 824 });
831 $scope.$broadcast('addCabecera',{ 825 $scope.$broadcast('addCabecera',{
832 label: 'Cotizacion:', 826 label: 'Cotizacion:',
833 valor: $filter('number')(cotizacion.COTIZACION, '2') 827 valor: $filter('number')(cotizacion.COTIZACION, '2')
834 }); 828 });
835 } 829 }
836 }, function() { 830 }, function() {
837 831
838 } 832 }
839 ); 833 );
840 }; 834 };
841 835
842 $scope.agregarATabla = function(key) { 836 $scope.agregarATabla = function(key) {
843 if(key === 13) { 837 if (key === 13) {
844 if($scope.articuloACargar.cantidad === undefined || 838 if ($scope.articuloACargar.cantidad === undefined ||
845 $scope.articuloACargar.cantidad === 0 || 839 $scope.articuloACargar.cantidad === 0 ||
846 $scope.articuloACargar.cantidad === null ) { 840 $scope.articuloACargar.cantidad === null ) {
847 focaModalService.alert('El valor debe ser al menos 1'); 841 focaModalService.alert('El valor debe ser al menos 1');
848 return; 842 return;
849 } 843 }
850 delete $scope.articuloACargar.sectorCodigo; 844 delete $scope.articuloACargar.sectorCodigo;
851 $scope.remito.articulosRemito.push($scope.articuloACargar); 845 $scope.remito.articulosRemito.push($scope.articuloACargar);
852 $scope.cargando = true; 846 $scope.cargando = true;
853 } 847 }
854 }; 848 };
855 849
856 $scope.quitarArticulo = function(key) { 850 $scope.quitarArticulo = function(key) {
857 $scope.remito.articulosRemito.splice(key, 1); 851 $scope.remito.articulosRemito.splice(key, 1);
858 }; 852 };
859 853
860 $scope.editarArticulo = function(key, articulo) { 854 $scope.editarArticulo = function(key, articulo) {
861 if (key === 13) { 855 if (key === 13) {
862 if (!articulo.cantidad || !articulo.precio) { 856 if (!articulo.cantidad || !articulo.precio) {
863 focaModalService.alert('Los valores deben ser al menos 1'); 857 focaModalService.alert('Los valores deben ser al menos 1');
864 return; 858 return;
865 } else if (articulo.cantidad < 0 || articulo.precio < 0) { 859 } else if (articulo.cantidad < 0 || articulo.precio < 0) {
866 focaModalService.alert('Los valores no pueden ser negativos'); 860 focaModalService.alert('Los valores no pueden ser negativos');
867 return; 861 return;
868 } 862 }
869 articulo.editCantidad = articulo.editPrecio = false; 863 articulo.editCantidad = articulo.editPrecio = false;
870 } 864 }
871 }; 865 };
872 866
873 $scope.cambioEdit = function(articulo, propiedad) { 867 $scope.cambioEdit = function(articulo, propiedad) {
874 if(propiedad === 'cantidad') { 868 if (propiedad === 'cantidad') {
875 articulo.editCantidad = true; 869 articulo.editCantidad = true;
876 }else if(propiedad === 'precio') { 870 } else if (propiedad === 'precio') {
877 articulo.editPrecio = true; 871 articulo.editPrecio = true;
878 } 872 }
879 }; 873 };
880 874
881 $scope.resetFilter = function() { 875 $scope.resetFilter = function() {
882 $scope.articuloACargar = {}; 876 $scope.articuloACargar = {};
883 $scope.cargando = true; 877 $scope.cargando = true;
884 }; 878 };
885 //Recibe aviso si el teclado está en uso 879 //Recibe aviso si el teclado está en uso
886 $rootScope.$on('usarTeclado', function(event, data) { 880 $rootScope.$on('usarTeclado', function(event, data) {
887 if(data) { 881 if (data) {
888 $scope.mostrarTeclado = true; 882 $scope.mostrarTeclado = true;
889 return; 883 return;
890 } 884 }
891 $scope.mostrarTeclado = false; 885 $scope.mostrarTeclado = false;
892 }); 886 });
893 887
894 $scope.selectFocus = function($event) { 888 $scope.selectFocus = function($event) {
895 // Si el teclado esta en uso no selecciona el valor 889 // Si el teclado esta en uso no selecciona el valor
896 if($scope.mostrarTeclado) { 890 if ($scope.mostrarTeclado) {
897 return; 891 return;
898 } 892 }
899 $event.target.select(); 893 $event.target.select();
900 }; 894 };
901 895
902 function addArrayCabecera(array) { 896 function addArrayCabecera(array) {
903 for(var i = 0; i < array.length; i++) { 897 for (var i = 0; i < array.length; i++) {
904 $scope.$broadcast('addCabecera',{ 898 $scope.$broadcast('addCabecera',{
905 label: array[i].label, 899 label: array[i].label,
906 valor: array[i].valor 900 valor: array[i].valor
907 }); 901 });
908 } 902 }
909 } 903 }
910 904
911 function rellenar(relleno, longitud) { 905 function rellenar(relleno, longitud) {
912 relleno = '' + relleno; 906 relleno = '' + relleno;
913 while (relleno.length < longitud) { 907 while (relleno.length < longitud) {
914 relleno = '0' + relleno; 908 relleno = '0' + relleno;
915 } 909 }
916 910
917 return relleno; 911 return relleno;
918 } 912 }
919 913
920 function varlidarRemitoFacturado() { 914 function varlidarRemitoFacturado() {
921 if($scope.remito.estado !== 5) { 915 if ($scope.remito.estado !== 5) {
922 return true; 916 return true;
923 }else { 917 } else {
924 focaModalService.alert('No se puede editar un remito facturado'); 918 focaModalService.alert('No se puede editar un remito facturado');
925 return false(); 919 return false();
926 } 920 }
927 } 921 }
928 922
929 function salir() { 923 function salir() {
930 var confirmacion = false; 924 var confirmacion = false;
931 925
932 if (!angular.equals($scope.remito, $scope.inicial)) { 926 if (!angular.equals($scope.remito, $scope.inicial)) {
933 confirmacion = true; 927 confirmacion = true;
934 } 928 }
935 929
936 if (confirmacion) { 930 if (confirmacion) {
937 focaModalService.confirm( 931 focaModalService.confirm(
938 '¿Está seguro de que desea salir? Se perderán todos los datos cargados.' 932 '¿Está seguro de que desea salir? Se perderán todos los datos cargados.'
939 ).then(function(data) { 933 ).then(function(data) {
940 if (data) { 934 if (data) {
941 $location.path('/'); 935 $location.path('/');
942 } 936 }
943 }); 937 });
944 } else { 938 } else {
945 $location.path('/'); 939 $location.path('/');
946 } 940 }
947 } 941 }
948 942
949 function enableObservaciones(val) { 943 function enableObservaciones(val) {
950 var boton = $scope.botonera.filter(function(botonObs) { 944 var boton = $scope.botonera.filter(function(botonObs) {
951 return botonObs.label === 'Observaciones'; 945 return botonObs.label === 'Observaciones';
952 }); 946 });
953 947
954 boton[0].disable = !val; 948 boton[0].disable = !val;
955 } 949 }
956 950
957 function setearRemito(remito) { 951 function setearRemito(remito) {
958 //añado cabeceras 952 //añado cabeceras
959 $scope.$broadcast('removeCabecera', 'Moneda:'); 953 $scope.$broadcast('removeCabecera', 'Moneda:');
960 $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); 954 $scope.$broadcast('removeCabecera', 'Fecha cotizacion:');
961 $scope.$broadcast('removeCabecera', 'Cotizacion:'); 955 $scope.$broadcast('removeCabecera', 'Cotizacion:');
962 956
963 var cabeceras = []; 957 var cabeceras = [];
964 958
965 if (remito.cotizacion.ID) { 959 if (remito.cotizacion.ID) {
966 cabeceras.push({ 960 cabeceras.push({
967 label: 'Moneda:', 961 label: 'Moneda:',
968 valor: remito.cotizacion.moneda.DETALLE 962 valor: remito.cotizacion.moneda.DETALLE
969 }); 963 });
970 cabeceras.push({ 964 cabeceras.push({
971 label: 'Fecha cotizacion:', 965 label: 'Fecha cotizacion:',
972 valor: $filter('date')(remito.cotizacion.FECHA, 966 valor: $filter('date')(remito.cotizacion.FECHA,
973 'dd/MM/yyyy') 967 'dd/MM/yyyy')
974 }); 968 });
975 cabeceras.push({ 969 cabeceras.push({
976 label: 'Cotizacion:', 970 label: 'Cotizacion:',
977 valor: $filter('number')(remito.cotizacion.VENDEDOR, 971 valor: $filter('number')(remito.cotizacion.VENDEDOR,
978 '2') 972 '2')
979 }); 973 });
980 } 974 }
981 if (remito.cliente.COD) { 975 if (remito.cliente.COD) {
982 cabeceras.push({ 976 cabeceras.push({
983 label: 'Cliente:', 977 label: 'Cliente:',
984 valor: $filter('rellenarDigitos')(remito.cliente.COD, 3) + ' - ' + 978 valor: $filter('rellenarDigitos')(remito.cliente.COD, 3) + ' - ' +
985 remito.cliente.NOM 979 remito.cliente.NOM
986 }); 980 });
987 cabeceras.push({ 981 cabeceras.push({
988 label: 'Domicilio:', 982 label: 'Domicilio:',
989 valor: remito.domicilioStamp 983 valor: remito.domicilioStamp
990 }); 984 });
991 } 985 }
992 if (remito.vendedor.NUM) { 986 if (remito.vendedor.NUM) {
993 cabeceras.push({ 987 cabeceras.push({
994 label: 'Vendedor:', 988 label: 'Vendedor:',
995 valor: $filter('rellenarDigitos')(remito.vendedor.NUM, 3) + 989 valor: $filter('rellenarDigitos')(remito.vendedor.NUM, 3) +
996 ' - ' + remito.vendedor.NOM 990 ' - ' + remito.vendedor.NOM
997 }); 991 });
998 } 992 }
999 if (remito.proveedor.COD) { 993 if (remito.proveedor.COD) {
1000 cabeceras.push({ 994 cabeceras.push({
1001 label: 'Proveedor:', 995 label: 'Proveedor:',
1002 valor: $filter('rellenarDigitos')(remito.proveedor.COD, 5) + 996 valor: $filter('rellenarDigitos')(remito.proveedor.COD, 5) +
1003 ' - ' + remito.proveedor.NOM 997 ' - ' + remito.proveedor.NOM
1004 }); 998 });
1005 } 999 }
1006 if (remito.flete !== undefined) { 1000 if (remito.flete !== undefined) {
1007 cabeceras.push({ 1001 cabeceras.push({
1008 label: 'Flete:', 1002 label: 'Flete:',
1009 valor: remito.fob === 1 ? 'FOB' : ( 1003 valor: remito.fob === 1 ? 'FOB' : (
1010 remito.flete === 1 ? 'Si' : 'No') 1004 remito.flete === 1 ? 'Si' : 'No')
1011 }); 1005 });
1012 } 1006 }
1013 if (remito.remitoPlazo) { 1007 if (remito.remitoPlazo) {
1014 cabeceras.push({ 1008 cabeceras.push({
1015 label: 'Precio condicion:', 1009 label: 'Precio condicion:',
1016 valor: valorPrecioCondicion() + ' ' + 1010 valor: valorPrecioCondicion() + ' ' +
1017 remitoBusinessService.plazoToString(remito.remitoPlazo) 1011 remitoBusinessService.plazoToString(remito.remitoPlazo)
1018 }); 1012 });
1019 } 1013 }
1020 1014
1021 function valorPrecioCondicion() { 1015 function valorPrecioCondicion() {
1022 if (remito.idPrecioCondicion > 0) { 1016 if (remito.idPrecioCondicion > 0) {
1023 return remito.precioCondicion.nombre; 1017 return remito.precioCondicion.nombre;
1024 } else { 1018 } else {
1025 return 'Ingreso Manual'; 1019 return 'Ingreso Manual';
1026 } 1020 }
1027 } 1021 }
1028 1022
1029 if (remito.flete === 1) { 1023 if (remito.flete === 1) {
1030 var cabeceraBomba = { 1024 var cabeceraBomba = {
1031 label: 'Bomba', 1025 label: 'Bomba',
1032 valor: remito.bomba === 1 ? 'Si' : 'No' 1026 valor: remito.bomba === 1 ? 'Si' : 'No'
1033 }; 1027 };
1034 if (remito.kilometros) { 1028 if (remito.kilometros) {
1035 var cabeceraKilometros = { 1029 var cabeceraKilometros = {
1036 label: 'Kilometros', 1030 label: 'Kilometros',
1037 valor: remito.kilometros 1031 valor: remito.kilometros
1038 }; 1032 };
1039 cabeceras.push(cabeceraKilometros); 1033 cabeceras.push(cabeceraKilometros);
1040 } 1034 }
1041 cabeceras.push(cabeceraBomba); 1035 cabeceras.push(cabeceraBomba);
1042 } 1036 }
1043 $scope.remito.articulosRemito = remito.articulosRemito; 1037 $scope.remito.articulosRemito = remito.articulosRemito;
1044 remitoBusinessService.calcularArticulos($scope.remito.articulosRemito, 1038 remitoBusinessService.calcularArticulos($scope.remito.articulosRemito,
1045 remito.cotizacion.VENDEDOR); 1039 remito.cotizacion.VENDEDOR);
1046 if (remito.idPrecioCondicion > 0) { 1040 if (remito.idPrecioCondicion > 0) {
1047 $scope.idLista = remito.precioCondicion.idListaPrecio; 1041 $scope.idLista = remito.precioCondicion.idListaPrecio;
1048 } else { 1042 } else {
1049 $scope.idLista = -1; 1043 $scope.idLista = -1;
1050 } 1044 }
1051 $scope.puntoVenta = rellenar(remito.sucursal, 4); 1045 $scope.puntoVenta = rellenar(remito.sucursal, 4);
1052 $scope.comprobante = rellenar(remito.numeroRemito, 8); 1046 $scope.comprobante = rellenar(remito.numeroRemito, 8);
1053 $scope.remito = remito; 1047 $scope.remito = remito;
1054 addArrayCabecera(cabeceras); 1048 addArrayCabecera(cabeceras);
1055 } 1049 }
1056 1050
1057 function getLSRemito() { 1051 function getLSRemito() {
1058 var remito = JSON.parse($localStorage.remito || null); 1052 var remito = JSON.parse($localStorage.remito || null);
1059 if (remito) { 1053 if (remito) {
1060 setearRemito(remito); 1054 setearRemito(remito);
1061 delete $localStorage.remito; 1055 delete $localStorage.remito;
1062 } 1056 }
1063 } 1057 }
1064 1058
1065 function deleteCliente() { 1059 function deleteCliente() {
1066 delete $scope.remito.domicilioStamp; 1060 delete $scope.remito.domicilioStamp;
1067 delete $scope.remito.puntosDescarga; 1061 delete $scope.remito.puntosDescarga;
1068 $scope.remito.domicilio = {dom: ''}; 1062 $scope.remito.domicilio = {dom: ''};
1069 $scope.remito.cliente = {}; 1063 $scope.remito.cliente = {};
1070 $scope.$broadcast('removeCabecera', 'Cliente:'); 1064 $scope.$broadcast('removeCabecera', 'Cliente:');
1071 $scope.$broadcast('removeCabecera', 'Domicilio:'); 1065 $scope.$broadcast('removeCabecera', 'Domicilio:');
1072 $scope.$broadcast('removeCabecera', 'Puntos de descarga:'); 1066 $scope.$broadcast('removeCabecera', 'Puntos de descarga:');
1073 } 1067 }
1074 } 1068
1075 ]); 1069 function abrirModalMail(id, cliente, numeroRemito) {
1076 1070 focaModalService.mail(
1071 {
1072 titulo: 'Comprobante de remito Nº ' + numeroRemito,
1073 descarga: {
1074 nombre: numeroRemito + '.pdf',
1075 url: '/remito/comprobante',
1076 },
1077 envio: {
1078 mailCliente: cliente.MAIL,
1079 url: '/remito/mail',
1080 },
1081 options: {
1082 idRemito: id
1083 }
1084 }
1085 )
1086 .then(function(res) {
1087 if (res === false) {
1088 abrirModalMail(id);
1089 focaModalService.alert('Descarga o envíe su remito ' +
1090 'antes de cerrar esta ventana');
src/js/controllerComprobante.js
1 angular.module('focaCrearRemito') File was deleted
2 .controller('focaRemitoComprobanteController', [
3 '$scope',
4 '$uibModalInstance',
5 'crearRemitoService',
6 '$filter',
7 'parametros',
8 'FileSaver',
9 'Blob',
10 function(
11 $scope, $uibModalInstance, crearRemitoService, $filter,
12 parametros, FileSaver, Blob
13 ) {
14 crearRemitoService.getRemitoById(parametros.idRemito).then(function(res) {
15
16 $scope.remito = res.data;
17 });
18 $scope.correoEnviado = false;
19 $scope.correoNoEnviado = false;
20 $scope.esperando = false;
21
22 $scope.aceptar = function() {
23 $uibModalInstance.close();
24 };
25
26 $scope.imprimir = function () {
27 $scope.esperando = true;
28 crearRemitoService.imprimirRemitoByIdRemito($scope.remito.id).then(
29 function(res) {
30 var data = new Blob([res.data], {type: 'application/pdf'});
31
32 FileSaver.saveAs(
33 data,
34 'RE-R-' + $filter('comprobante')([
35 $scope.remito.sucursal,
36 $scope.remito.numeroRemito
37 ]) + '.pdf'
38 );
39 $scope.esperando = false;
40 }
41 );
42 };
43
44 $scope.enviarCorreo = function(key) {
45 if(key !== 13) return;
46 $scope.esperando = true;
47 var options = {
48 para: $scope.remito.cliente.MAIL,
49 remito: $scope.remito.id
50 };
51
52 crearRemitoService.enviarCorreo(options).then(function() {
53 $scope.correoEnviado = true;
54 $scope.esperando = false;
55 }, function() {
56 $scope.esperando = false;
57 $scope.correoNoEnviado = true;
58 });
59 };
60 }
61 ]);
62 1 angular.module('focaCrearRemito')
1 angular.module('focaCrearRemito') 1 angular.module('focaCrearRemito')
2 .service('crearRemitoService', ['$http', 'API_ENDPOINT', 2 .service('crearRemitoService', ['$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 crearRemito: function(remito) { 6 crearRemito: function(remito) {
7 // TODO: Cambiar para usar el servicio /remito 7 // TODO: Cambiar para usar el servicio /remito
8 return $http.post(route + '/remito', remito); 8 return $http.post(route + '/remito', remito);
9 }, 9 },
10 getRemitoById: function(id) { 10 getRemitoById: function(id) {
11 return $http.get(route + '/remito/obtener/' + id); 11 return $http.get(route + '/remito/obtener/' + id);
12 }, 12 },
13 obtenerRemito: function() { 13 obtenerRemito: function() {
14 return $http.get(route +'/nota-pedido'); 14 return $http.get(route +'/nota-pedido');
15 }, 15 },
16 setRemito: function(remito) { 16 setRemito: function(remito) {
17 this.remito = remito; 17 this.remito = remito;
18 }, 18 },
19 clearRemito: function() { 19 clearRemito: function() {
20 this.remito = undefined; 20 this.remito = undefined;
21 }, 21 },
22 getRemito: function() { 22 getRemito: function() {
23 return this.remito; 23 return this.remito;
24 }, 24 },
25 getArticulosByIdRemito: function(id) { 25 getArticulosByIdRemito: function(id) {
26 return $http.get(route+'/articulos/nota-pedido/'+id); 26 return $http.get(route+'/articulos/nota-pedido/'+id);
27 }, 27 },
28 crearArticulosParaRemito: function(articuloRemito) { 28 crearArticulosParaRemito: function(articuloRemito) {
29 return $http.post(route + '/articulos/remito', 29 return $http.post(route + '/articulos/remito',
30 {articuloRemito: articuloRemito}); 30 {articuloRemito: articuloRemito});
31 }, 31 },
32 getDomiciliosByIdRemito: function(id) { 32 getDomiciliosByIdRemito: function(id) {
33 return $http.get(route +'/nota-pedido/'+id+'/domicilios'); 33 return $http.get(route +'/nota-pedido/'+id+'/domicilios');
34 }, 34 },
35 getDomiciliosByIdCliente: function(id) { 35 getDomiciliosByIdCliente: function(id) {
36 var idTipoEntrega = 2;//Solo traigo los domicilios que tienen tipo 2 (tipo entrega) 36 var idTipoEntrega = 2;//Solo traigo los domicilios que tienen tipo 2 (tipo entrega)
37 return $http.get(route + '/domicilio/tipo/' + idTipoEntrega + '/cliente/' + id ); 37 return $http.get(route + '/domicilio/tipo/' + idTipoEntrega + '/cliente/' + id );
38 }, 38 },
39 getPrecioCondicion: function() { 39 getPrecioCondicion: function() {
40 return $http.get(route + '/precio-condicion'); 40 return $http.get(route + '/precio-condicion');
41 }, 41 },
42 getPrecioCondicionById: function(id) { 42 getPrecioCondicionById: function(id) {
43 return $http.get(route + '/precio-condicion/' + id); 43 return $http.get(route + '/precio-condicion/' + id);
44 }, 44 },
45 getPlazoPagoByPrecioCondicion: function(id) { 45 getPlazoPagoByPrecioCondicion: function(id) {
46 return $http.get(route + '/plazo-pago/precio-condicion/'+ id); 46 return $http.get(route + '/plazo-pago/precio-condicion/'+ id);
47 }, 47 },
48 crearFlete: function(flete) { 48 crearFlete: function(flete) {
49 return $http.post(route + '/flete', {flete : flete}); 49 return $http.post(route + '/flete', {flete : flete});
50 }, 50 },
51 crearPlazosParaRemito: function(plazos) { 51 crearPlazosParaRemito: function(plazos) {
52 return $http.post(route + '/plazo-pago/remito', plazos); 52 return $http.post(route + '/plazo-pago/remito', plazos);
53 }, 53 },
54 getCotizacionByIdMoneda: function(id) { 54 getCotizacionByIdMoneda: function(id) {
55 return $http.get(route + '/moneda/' + id); 55 return $http.get(route + '/moneda/' + id);
56 }, 56 },
57 crearEstadoParaRemito: function(estado) { 57 crearEstadoParaRemito: function(estado) {
58 return $http.post(route + '/estado', {estado: estado}); 58 return $http.post(route + '/estado', {estado: estado});
59 }, 59 },
60 getNumeroRemito: function() { 60 getNumeroRemito: function() {
61 return $http.get(route + '/remito/numero-siguiente'); 61 return $http.get(route + '/remito/numero-siguiente');
62 }, 62 },
63 imprimirRemitoByIdRemito: function(idRemito, original) { 63 imprimirRemitoByIdRemito: function(idRemito) {
64 var tipo = original ? '/original' : ''; 64 return $http.get(route + '/remito/comprobante/' + idRemito , {
65 return $http.get(route + '/remito/comprobante/' + idRemito + tipo, {
66 responseType: 'arraybuffer' 65 responseType: 'arraybuffer'
67 }); 66 });
68 }, 67 },
69 getPuntosDescargaByClienDom: function(idDomicilio, idCliente) { 68 getPuntosDescargaByClienDom: function(idDomicilio, idCliente) {
70 return $http.get(API_ENDPOINT.URL + '/punto-descarga/' + 69 return $http.get(API_ENDPOINT.URL + '/punto-descarga/' +
71 idDomicilio + '/' + idCliente); 70 idDomicilio + '/' + idCliente);
72 }, 71 },
73 enviarCorreo: function(options) { 72 enviarCorreo: function(options) {
74 return $http.post(API_ENDPOINT.URL + '/remito/mail', options); 73 return $http.post(API_ENDPOINT.URL + '/remito/mail', options);
75 }, 74 },
76 getBotonera: function() { 75 getBotonera: function() {
77 return [ 76 return [
78 { 77 {
79 label: 'Nota pedido', 78 label: 'Nota pedido',
80 image: 'notaDePedido.png' 79 image: 'notaDePedido.png'
81 }, 80 },
82 { 81 {
83 label: 'Cliente', 82 label: 'Cliente',
84 image: 'cliente.png' 83 image: 'cliente.png'
85 }, 84 },
86 { 85 {
87 label: 'Transportista', 86 label: 'Transportista',
88 image: 'proveedor.png' 87 image: 'proveedor.png'
89 }, 88 },
90 { 89 {
91 label: 'Moneda', 90 label: 'Moneda',
92 image: 'moneda.png' 91 image: 'moneda.png'
93 }, 92 },
94 { 93 {
95 label: 'Precios y condiciones', 94 label: 'Precios y condiciones',
96 image: 'precios-condiciones.png' 95 image: 'precios-condiciones.png'
97 }, 96 },
98 { 97 {
99 label: 'Productos', 98 label: 'Productos',
100 image: 'productos.png' 99 image: 'productos.png'
101 }, 100 },
102 { 101 {
103 label: 'Observaciones', 102 label: 'Observaciones',
104 image: 'botonObservaciones.png', 103 image: 'botonObservaciones.png',
105 disable: true 104 disable: true
106 } 105 }
107 ]; 106 ];
108 } 107 }
109 }; 108 };
110 }]); 109 }]);
111 110
src/views/remito-comprobante.html
1 <div class="modal-header"> File was deleted
2 <h5>Comprobante de remito Nº
3 <span
4 ng-bind="[remito.sucursal, remito.numeroRemito] | comprobante">
5 </span>
6 </h5>
7 </div>
8 <div class="modal-body">
9 <div class="col-12">
10 <label
11 class="col-12 bg-success text-white"
12 ng-show="correoEnviado">Correo enviado con éxito</label>
13 <label
14 class="col-12 bg-danger text-white"
15 ng-show="correoNoEnviado">Hubo un error al enviar el correo</label>
16 <label>Enviar correo a </label>
17 <input
18 class="form-control"
19 ng-model="remito.cliente.MAIL"
20 ng-click="enviarCorreo($event.keyCode)"/>
21 </div>
22 </div>
23 <div class="modal-footer">
24 <button
25 type="button"
26 class="btn btn-info"
27 ng-click="imprimir()"
28 ladda="esperando"
29 >Imprimir</button>
30 <button
31 type="button"
32 class="btn btn-primary"
33 ng-click="aceptar()"
34 ladda="esperando"
35 >Aceptar</button>
36 <button
37 type="button"
38 class="btn btn-primary"
39 ng-click="enviarCorreo(13)"
40 ladda="esperando"
41 >Enviar</button>
42 </div>
43 1 <div class="modal-header">