Commit 5e1a7f48ec41637e22d285463835941706586196

Authored by Eric Fernandez
Exists in master

Merge branch 'master' into 'master'

Master

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