Commit ea05af249eb4b7ae764af1da3a8315bb60a5d288

Authored by Eric Fernandez
1 parent 5e1a7f48ec
Exists in master

envío idRemito a para el comprobante, total de remito siempre en pesos

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() * $scope.remito.cotizacion.VENDEDOR,
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.VENDEDOR);
391 391
392 focaBotoneraLateralService.endGuardar(true); 392 focaBotoneraLateralService.endGuardar(true);
393 $scope.saveLoading = false; 393 $scope.saveLoading = false;
394 394
395 //TODO: updatear plazos 395 //TODO: updatear plazos
396 if($scope.remito.id === 0) { 396 if($scope.remito.id === 0) {
397 $scope.remito.id = data.data.id; 397 $scope.remito.id = data.data.id;
398 var plazos = $scope.plazosPagos; 398 var plazos = $scope.plazosPagos;
399 399
400 for(var j = 0; j < plazos.length; j++) { 400 for(var j = 0; j < plazos.length; j++) {
401 var json = { 401 var json = {
402 idRemito: $scope.remito.id, 402 idRemito: $scope.remito.id,
403 dias: plazos[j].dias 403 dias: plazos[j].dias
404 }; 404 };
405 crearRemitoService.crearPlazosParaRemito(json); 405 crearRemitoService.crearPlazosParaRemito(json);
406 } 406 }
407 } 407 }
408 408
409 $uibModal.open({ 409 $uibModal.open({
410 templateUrl: 'remito-comprobante.html', 410 templateUrl: 'remito-comprobante.html',
411 controller: 'focaRemitoComprobanteController', 411 controller: 'focaRemitoComprobanteController',
412 resolve: { 412 resolve: {
413 parametros: { 413 parametros: {
414 remito: $scope.remito 414 idRemito: data.data.id
415 } 415 }
416 } 416 }
417 }); 417 });
418 418
419 init(); 419 init();
420 420
421 }, function(error) { 421 }, function(error) {
422 focaModalService.alert('Hubo un error al crear el remito'); 422 focaModalService.alert('Hubo un error al crear el remito');
423 focaBotoneraLateralService.endGuardar(); 423 focaBotoneraLateralService.endGuardar();
424 $scope.saveLoading = false; 424 $scope.saveLoading = false;
425 console.info(error); 425 console.info(error);
426 } 426 }
427 ); 427 );
428 }; 428 };
429 429
430 $scope.seleccionarProductos = function() { 430 $scope.seleccionarProductos = function() {
431 if($scope.idLista === undefined) { 431 if($scope.idLista === undefined) {
432 focaModalService.alert( 432 focaModalService.alert(
433 'Primero seleccione una lista de precio y condicion'); 433 'Primero seleccione una lista de precio y condicion');
434 return; 434 return;
435 } 435 }
436 var modalInstance = $uibModal.open( 436 var modalInstance = $uibModal.open(
437 { 437 {
438 ariaLabelledBy: 'Busqueda de Productos', 438 ariaLabelledBy: 'Busqueda de Productos',
439 templateUrl: 'modal-busqueda-productos.html', 439 templateUrl: 'modal-busqueda-productos.html',
440 controller: 'modalBusquedaProductosCtrl', 440 controller: 'modalBusquedaProductosCtrl',
441 resolve: { 441 resolve: {
442 parametroProducto: { 442 parametroProducto: {
443 idLista: $scope.idLista, 443 idLista: $scope.idLista,
444 cotizacion: $scope.remito.cotizacion.COTIZACION, 444 cotizacion: $scope.remito.cotizacion.COTIZACION,
445 simbolo: $scope.remito.moneda.simbolo 445 simbolo: $scope.remito.moneda.simbolo
446 } 446 }
447 }, 447 },
448 size: 'lg' 448 size: 'lg'
449 } 449 }
450 ); 450 );
451 modalInstance.result.then( 451 modalInstance.result.then(
452 function(producto) { 452 function(producto) {
453 var newArt = 453 var newArt =
454 { 454 {
455 id: 0, 455 id: 0,
456 codigo: producto.codigo, 456 codigo: producto.codigo,
457 sector: producto.sector, 457 sector: producto.sector,
458 sectorCodigo: producto.sector + '-' + producto.codigo, 458 sectorCodigo: producto.sector + '-' + producto.codigo,
459 descripcion: producto.descripcion, 459 descripcion: producto.descripcion,
460 item: $scope.articulosTabla.length + 1, 460 item: $scope.articulosTabla.length + 1,
461 nombre: producto.descripcion, 461 nombre: producto.descripcion,
462 precio: parseFloat(producto.precio.toFixed(4)), 462 precio: parseFloat(producto.precio.toFixed(4)),
463 costoUnitario: producto.costo, 463 costoUnitario: producto.costo,
464 editCantidad: false, 464 editCantidad: false,
465 editPrecio: false, 465 editPrecio: false,
466 rubro: producto.CodRub, 466 rubro: producto.CodRub,
467 exentoUnitario: producto.precio, 467 exentoUnitario: producto.precio,
468 ivaUnitario: producto.IMPIVA, 468 ivaUnitario: producto.IMPIVA,
469 impuestoInternoUnitario: producto.ImpInt, 469 impuestoInternoUnitario: producto.ImpInt,
470 impuestoInterno1Unitario: producto.ImpInt2, 470 impuestoInterno1Unitario: producto.ImpInt2,
471 impuestoInterno2Unitario: producto.ImpInt3, 471 impuestoInterno2Unitario: producto.ImpInt3,
472 precioLista: producto.precio, 472 precioLista: producto.precio,
473 combustible: 1, 473 combustible: 1,
474 facturado: 0 474 facturado: 0
475 }; 475 };
476 $scope.articuloACargar = newArt; 476 $scope.articuloACargar = newArt;
477 $scope.cargando = false; 477 $scope.cargando = false;
478 }, function() { 478 }, function() {
479 // funcion ejecutada cuando se cancela el modal 479 // funcion ejecutada cuando se cancela el modal
480 } 480 }
481 ); 481 );
482 }; 482 };
483 483
484 $scope.seleccionarPuntosDeDescarga = function() { 484 $scope.seleccionarPuntosDeDescarga = function() {
485 if(!$scope.remito.cliente.COD || !$scope.remito.domicilio.id) { 485 if(!$scope.remito.cliente.COD || !$scope.remito.domicilio.id) {
486 focaModalService.alert('Primero seleccione un cliente y un domicilio'); 486 focaModalService.alert('Primero seleccione un cliente y un domicilio');
487 return; 487 return;
488 }else { 488 }else {
489 var modalInstance = $uibModal.open( 489 var modalInstance = $uibModal.open(
490 { 490 {
491 ariaLabelledBy: 'Búsqueda de Puntos de descarga', 491 ariaLabelledBy: 'Búsqueda de Puntos de descarga',
492 templateUrl: 'modal-punto-descarga.html', 492 templateUrl: 'modal-punto-descarga.html',
493 controller: 'focaModalPuntoDescargaController', 493 controller: 'focaModalPuntoDescargaController',
494 size: 'lg', 494 size: 'lg',
495 resolve: { 495 resolve: {
496 filters: { 496 filters: {
497 idDomicilio: $scope.remito.domicilio.id, 497 idDomicilio: $scope.remito.domicilio.id,
498 idCliente: $scope.remito.cliente.COD, 498 idCliente: $scope.remito.cliente.COD,
499 articulos: $scope.articulosTabla, 499 articulos: $scope.articulosTabla,
500 puntosDescarga: $scope.remito.domicilio.puntosDescarga 500 puntosDescarga: $scope.remito.domicilio.puntosDescarga
501 } 501 }
502 } 502 }
503 } 503 }
504 ); 504 );
505 modalInstance.result.then( 505 modalInstance.result.then(
506 function(puntosDescarga) { 506 function(puntosDescarga) {
507 $scope.remito.puntosDescarga = puntosDescarga; 507 $scope.remito.puntosDescarga = puntosDescarga;
508 508
509 //AGREGO PUNTOS DE DESCARGA A CABECERA 509 //AGREGO PUNTOS DE DESCARGA A CABECERA
510 var puntosStamp = ''; 510 var puntosStamp = '';
511 puntosDescarga.forEach(function(punto, idx, arr) { 511 puntosDescarga.forEach(function(punto, idx, arr) {
512 puntosStamp += punto.descripcion; 512 puntosStamp += punto.descripcion;
513 if((idx + 1) !== arr.length) puntosStamp += ', '; 513 if((idx + 1) !== arr.length) puntosStamp += ', ';
514 }); 514 });
515 515
516 $scope.$broadcast('addCabecera', { 516 $scope.$broadcast('addCabecera', {
517 label: 'Puntos de descarga:', 517 label: 'Puntos de descarga:',
518 valor: puntosStamp 518 valor: puntosStamp
519 }); 519 });
520 }, function() { 520 }, function() {
521 $scope.abrirModalDomicilios($scope.cliente); 521 $scope.abrirModalDomicilios($scope.cliente);
522 } 522 }
523 ); 523 );
524 } 524 }
525 }; 525 };
526 526
527 $scope.seleccionarVendedor = function() { 527 $scope.seleccionarVendedor = function() {
528 if(varlidarRemitoFacturado()) { 528 if(varlidarRemitoFacturado()) {
529 var parametrosModal = { 529 var parametrosModal = {
530 titulo: 'Búsqueda vendedores', 530 titulo: 'Búsqueda vendedores',
531 query: '/vendedor', 531 query: '/vendedor',
532 columnas: [ 532 columnas: [
533 { 533 {
534 propiedad: 'NUM', 534 propiedad: 'NUM',
535 nombre: 'Código', 535 nombre: 'Código',
536 filtro: { 536 filtro: {
537 nombre: 'rellenarDigitos', 537 nombre: 'rellenarDigitos',
538 parametro: 3 538 parametro: 3
539 } 539 }
540 }, 540 },
541 { 541 {
542 propiedad: 'NOM', 542 propiedad: 'NOM',
543 nombre: 'Nombre' 543 nombre: 'Nombre'
544 } 544 }
545 ], 545 ],
546 size: 'md' 546 size: 'md'
547 }; 547 };
548 focaModalService.modal(parametrosModal).then( 548 focaModalService.modal(parametrosModal).then(
549 function(vendedor) { 549 function(vendedor) {
550 $scope.$broadcast('addCabecera',{ 550 $scope.$broadcast('addCabecera',{
551 label: 'Vendedor:', 551 label: 'Vendedor:',
552 valor: $filter('rellenarDigitos')(vendedor.NUM, 3) + ' - ' + 552 valor: $filter('rellenarDigitos')(vendedor.NUM, 3) + ' - ' +
553 vendedor.NOM 553 vendedor.NOM
554 }); 554 });
555 $scope.remito.idVendedor = vendedor.id; 555 $scope.remito.idVendedor = vendedor.id;
556 $scope.vendedor = vendedor; 556 $scope.vendedor = vendedor;
557 }, function() { 557 }, function() {
558 558
559 } 559 }
560 ); 560 );
561 } 561 }
562 }; 562 };
563 563
564 $scope.seleccionarProveedor = function() { 564 $scope.seleccionarProveedor = function() {
565 if(varlidarRemitoFacturado()) { 565 if(varlidarRemitoFacturado()) {
566 var parametrosModal = { 566 var parametrosModal = {
567 titulo: 'Búsqueda de Proveedor', 567 titulo: 'Búsqueda de Proveedor',
568 query: '/proveedor', 568 query: '/proveedor',
569 columnas: [ 569 columnas: [
570 { 570 {
571 nombre: 'Código', 571 nombre: 'Código',
572 propiedad: 'COD', 572 propiedad: 'COD',
573 filtro: { 573 filtro: {
574 nombre: 'rellenarDigitos', 574 nombre: 'rellenarDigitos',
575 parametro: 5 575 parametro: 5
576 } 576 }
577 }, 577 },
578 { 578 {
579 nombre: 'Nombre', 579 nombre: 'Nombre',
580 propiedad: 'NOM' 580 propiedad: 'NOM'
581 }, 581 },
582 { 582 {
583 nombre: 'CUIT', 583 nombre: 'CUIT',
584 propiedad: 'CUIT' 584 propiedad: 'CUIT'
585 } 585 }
586 ], 586 ],
587 tipo: 'POST', 587 tipo: 'POST',
588 json: {razonCuitCod: ''} 588 json: {razonCuitCod: ''}
589 }; 589 };
590 focaModalService.modal(parametrosModal).then( 590 focaModalService.modal(parametrosModal).then(
591 function(proveedor) { 591 function(proveedor) {
592 $scope.remito.idProveedor = proveedor.COD; 592 $scope.remito.idProveedor = proveedor.COD;
593 $scope.$broadcast('addCabecera',{ 593 $scope.$broadcast('addCabecera',{
594 label: 'Proveedor:', 594 label: 'Proveedor:',
595 valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + 595 valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' +
596 proveedor.NOM 596 proveedor.NOM
597 }); 597 });
598 }, function() { 598 }, function() {
599 599
600 } 600 }
601 ); 601 );
602 } 602 }
603 }; 603 };
604 604
605 $scope.seleccionarCliente = function() { 605 $scope.seleccionarCliente = function() {
606 if(!$scope.vendedor) { 606 if(!$scope.vendedor) {
607 focaModalService.alert('Primero seleccione un vendedor'); 607 focaModalService.alert('Primero seleccione un vendedor');
608 return; 608 return;
609 } 609 }
610 610
611 if(varlidarRemitoFacturado()) { 611 if(varlidarRemitoFacturado()) {
612 var modalInstance = $uibModal.open( 612 var modalInstance = $uibModal.open(
613 { 613 {
614 ariaLabelledBy: 'Busqueda de Cliente', 614 ariaLabelledBy: 'Busqueda de Cliente',
615 templateUrl: 'foca-busqueda-cliente-modal.html', 615 templateUrl: 'foca-busqueda-cliente-modal.html',
616 controller: 'focaBusquedaClienteModalController', 616 controller: 'focaBusquedaClienteModalController',
617 resolve: { 617 resolve: {
618 vendedor: function() { return $scope.vendedor; } 618 vendedor: function() { return $scope.vendedor; }
619 }, 619 },
620 size: 'lg' 620 size: 'lg'
621 } 621 }
622 ); 622 );
623 modalInstance.result.then( 623 modalInstance.result.then(
624 function(cliente) { 624 function(cliente) {
625 $scope.abrirModalDomicilios(cliente); 625 $scope.abrirModalDomicilios(cliente);
626 $scope.cliente = cliente; 626 $scope.cliente = cliente;
627 }, function() { 627 }, function() {
628 628
629 } 629 }
630 ); 630 );
631 } 631 }
632 }; 632 };
633 633
634 $scope.abrirModalDomicilios = function(cliente) { 634 $scope.abrirModalDomicilios = function(cliente) {
635 var modalInstanceDomicilio = $uibModal.open( 635 var modalInstanceDomicilio = $uibModal.open(
636 { 636 {
637 ariaLabelledBy: 'Busqueda de Domicilios', 637 ariaLabelledBy: 'Busqueda de Domicilios',
638 templateUrl: 'modal-domicilio.html', 638 templateUrl: 'modal-domicilio.html',
639 controller: 'focaModalDomicilioController', 639 controller: 'focaModalDomicilioController',
640 size: 'lg', 640 size: 'lg',
641 resolve: { 641 resolve: {
642 idCliente: function() { return cliente.cod; }, 642 idCliente: function() { return cliente.cod; },
643 esNuevo: function() { return cliente.esNuevo; } 643 esNuevo: function() { return cliente.esNuevo; }
644 } 644 }
645 } 645 }
646 ); 646 );
647 modalInstanceDomicilio.result.then( 647 modalInstanceDomicilio.result.then(
648 function(domicilio) { 648 function(domicilio) {
649 $scope.remito.domicilio = domicilio; 649 $scope.remito.domicilio = domicilio;
650 $scope.remito.cliente = { 650 $scope.remito.cliente = {
651 COD: cliente.cod, 651 COD: cliente.cod,
652 CUIT: cliente.cuit, 652 CUIT: cliente.cuit,
653 NOM: cliente.nom, 653 NOM: cliente.nom,
654 MAIL: cliente.mail 654 MAIL: cliente.mail
655 }; 655 };
656 656
657 657
658 var domicilioStamp = 658 var domicilioStamp =
659 domicilio.Calle + ' ' + domicilio.Numero + ', ' + 659 domicilio.Calle + ' ' + domicilio.Numero + ', ' +
660 domicilio.Localidad + ', ' + domicilio.Provincia; 660 domicilio.Localidad + ', ' + domicilio.Provincia;
661 $scope.remito.domicilioStamp = domicilioStamp; 661 $scope.remito.domicilioStamp = domicilioStamp;
662 662
663 $scope.$broadcast('addCabecera',{ 663 $scope.$broadcast('addCabecera',{
664 label: 'Cliente:', 664 label: 'Cliente:',
665 valor: $filter('rellenarDigitos')(cliente.cod, 3) + ' - ' + cliente.nom 665 valor: $filter('rellenarDigitos')(cliente.cod, 3) + ' - ' + cliente.nom
666 }); 666 });
667 $scope.$broadcast('addCabecera',{ 667 $scope.$broadcast('addCabecera',{
668 label: 'Domicilio:', 668 label: 'Domicilio:',
669 valor: domicilioStamp 669 valor: domicilioStamp
670 }); 670 });
671 671
672 if(domicilio.verPuntos) { 672 if(domicilio.verPuntos) {
673 delete $scope.remito.domicilio.verPuntos; 673 delete $scope.remito.domicilio.verPuntos;
674 $scope.seleccionarPuntosDeDescarga(); 674 $scope.seleccionarPuntosDeDescarga();
675 }else { 675 }else {
676 crearRemitoService 676 crearRemitoService
677 .getPuntosDescargaByClienDom(domicilio.id, cliente.cod) 677 .getPuntosDescargaByClienDom(domicilio.id, cliente.cod)
678 .then(function(res) { 678 .then(function(res) {
679 if(res.data.length) $scope.seleccionarPuntosDeDescarga(); 679 if(res.data.length) $scope.seleccionarPuntosDeDescarga();
680 }); 680 });
681 } 681 }
682 }, function() { 682 }, function() {
683 $scope.seleccionarCliente(); 683 $scope.seleccionarCliente();
684 return; 684 return;
685 } 685 }
686 ); 686 );
687 }; 687 };
688 688
689 $scope.mostrarFichaCliente = function() { 689 $scope.mostrarFichaCliente = function() {
690 $uibModal.open( 690 $uibModal.open(
691 { 691 {
692 ariaLabelledBy: 'Datos del Cliente', 692 ariaLabelledBy: 'Datos del Cliente',
693 templateUrl: 'foca-crear-remito-ficha-cliente.html', 693 templateUrl: 'foca-crear-remito-ficha-cliente.html',
694 controller: 'focaCrearRemitoFichaClienteController', 694 controller: 'focaCrearRemitoFichaClienteController',
695 size: 'lg' 695 size: 'lg'
696 } 696 }
697 ); 697 );
698 }; 698 };
699 699
700 $scope.getTotal = function() { 700 $scope.getTotal = function() {
701 var total = 0; 701 var total = 0;
702 var arrayTempArticulos = $scope.articulosTabla; 702 var arrayTempArticulos = $scope.articulosTabla;
703 for(var i = 0; i < arrayTempArticulos.length; i++) { 703 for(var i = 0; i < arrayTempArticulos.length; i++) {
704 total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; 704 total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad;
705 } 705 }
706 return parseFloat(total.toFixed(2)); 706 return parseFloat(total.toFixed(2));
707 }; 707 };
708 708
709 $scope.getSubTotal = function() { 709 $scope.getSubTotal = function() {
710 if($scope.articuloACargar) { 710 if($scope.articuloACargar) {
711 return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; 711 return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad;
712 } 712 }
713 }; 713 };
714 714
715 $scope.seleccionarPreciosYCondiciones = function() { 715 $scope.seleccionarPreciosYCondiciones = function() {
716 if(varlidarRemitoFacturado()) { 716 if(varlidarRemitoFacturado()) {
717 var modalInstance = $uibModal.open( 717 var modalInstance = $uibModal.open(
718 { 718 {
719 ariaLabelledBy: 'Busqueda de Precio Condición', 719 ariaLabelledBy: 'Busqueda de Precio Condición',
720 templateUrl: 'modal-precio-condicion.html', 720 templateUrl: 'modal-precio-condicion.html',
721 controller: 'focaModalPrecioCondicionController', 721 controller: 'focaModalPrecioCondicionController',
722 size: 'lg' 722 size: 'lg'
723 } 723 }
724 ); 724 );
725 modalInstance.result.then( 725 modalInstance.result.then(
726 function(precioCondicion) { 726 function(precioCondicion) {
727 var cabecera = ''; 727 var cabecera = '';
728 var plazosConcat = ''; 728 var plazosConcat = '';
729 if(!Array.isArray(precioCondicion)) { 729 if(!Array.isArray(precioCondicion)) {
730 $scope.remito.idPrecioCondicion = precioCondicion.id; 730 $scope.remito.idPrecioCondicion = precioCondicion.id;
731 $scope.plazosPagos = precioCondicion.plazoPago; 731 $scope.plazosPagos = precioCondicion.plazoPago;
732 $scope.idLista = precioCondicion.idListaPrecio; 732 $scope.idLista = precioCondicion.idListaPrecio;
733 for(var i = 0; i < precioCondicion.plazoPago.length; i++) { 733 for(var i = 0; i < precioCondicion.plazoPago.length; i++) {
734 plazosConcat += precioCondicion.plazoPago[i].dias + ' '; 734 plazosConcat += precioCondicion.plazoPago[i].dias + ' ';
735 } 735 }
736 cabecera = $filter('rellenarDigitos')(precioCondicion.id, 4) + 736 cabecera = $filter('rellenarDigitos')(precioCondicion.id, 4) +
737 ' - ' + precioCondicion.nombre + ' ' + plazosConcat.trim(); 737 ' - ' + precioCondicion.nombre + ' ' + plazosConcat.trim();
738 }else { //Cuando se ingresan los plazos manualmente 738 }else { //Cuando se ingresan los plazos manualmente
739 $scope.remito.idPrecioCondicion = 0; 739 $scope.remito.idPrecioCondicion = 0;
740 //-1, el modal productos busca todos los productos 740 //-1, el modal productos busca todos los productos
741 $scope.idLista = -1; 741 $scope.idLista = -1;
742 $scope.plazosPagos = precioCondicion; 742 $scope.plazosPagos = precioCondicion;
743 for(var j = 0; j < precioCondicion.length; j++) { 743 for(var j = 0; j < precioCondicion.length; j++) {
744 plazosConcat += precioCondicion[j].dias + ' '; 744 plazosConcat += precioCondicion[j].dias + ' ';
745 } 745 }
746 cabecera = 'Ingreso manual ' + plazosConcat.trim(); 746 cabecera = 'Ingreso manual ' + plazosConcat.trim();
747 } 747 }
748 $scope.articulosTabla = []; 748 $scope.articulosTabla = [];
749 $scope.$broadcast('addCabecera',{ 749 $scope.$broadcast('addCabecera',{
750 label: 'Precios y condiciones:', 750 label: 'Precios y condiciones:',
751 valor: cabecera 751 valor: cabecera
752 }); 752 });
753 }, function() { 753 }, function() {
754 754
755 } 755 }
756 ); 756 );
757 } 757 }
758 }; 758 };
759 759
760 $scope.seleccionarFlete = function() { 760 $scope.seleccionarFlete = function() {
761 if(varlidarRemitoFacturado()) { 761 if(varlidarRemitoFacturado()) {
762 var modalInstance = $uibModal.open( 762 var modalInstance = $uibModal.open(
763 { 763 {
764 ariaLabelledBy: 'Busqueda de Flete', 764 ariaLabelledBy: 'Busqueda de Flete',
765 templateUrl: 'modal-flete.html', 765 templateUrl: 'modal-flete.html',
766 controller: 'focaModalFleteController', 766 controller: 'focaModalFleteController',
767 size: 'lg', 767 size: 'lg',
768 resolve: { 768 resolve: {
769 parametrosFlete: 769 parametrosFlete:
770 function() { 770 function() {
771 return { 771 return {
772 flete: $scope.remito.flete ? '1' : 772 flete: $scope.remito.flete ? '1' :
773 ($scope.remito.fob ? 'FOB' : 773 ($scope.remito.fob ? 'FOB' :
774 ($scope.remito.flete === undefined ? null : '0')), 774 ($scope.remito.flete === undefined ? null : '0')),
775 bomba: $scope.remito.bomba ? '1' : 775 bomba: $scope.remito.bomba ? '1' :
776 ($scope.remito.bomba === undefined ? null : '0'), 776 ($scope.remito.bomba === undefined ? null : '0'),
777 kilometros: $scope.remito.kilometros 777 kilometros: $scope.remito.kilometros
778 }; 778 };
779 } 779 }
780 } 780 }
781 } 781 }
782 ); 782 );
783 modalInstance.result.then( 783 modalInstance.result.then(
784 function(datos) { 784 function(datos) {
785 $scope.remito.flete = datos.flete; 785 $scope.remito.flete = datos.flete;
786 $scope.remito.fob = datos.FOB; 786 $scope.remito.fob = datos.FOB;
787 $scope.remito.bomba = datos.bomba; 787 $scope.remito.bomba = datos.bomba;
788 $scope.remito.kilometros = datos.kilometros; 788 $scope.remito.kilometros = datos.kilometros;
789 789
790 $scope.$broadcast('addCabecera',{ 790 $scope.$broadcast('addCabecera',{
791 label: 'Flete:', 791 label: 'Flete:',
792 valor: datos.flete ? 'Si' : ($scope.remito.fob ? 'FOB' : 'No') 792 valor: datos.flete ? 'Si' : ($scope.remito.fob ? 'FOB' : 'No')
793 }); 793 });
794 if(datos.flete) { 794 if(datos.flete) {
795 $scope.$broadcast('addCabecera',{ 795 $scope.$broadcast('addCabecera',{
796 label: 'Bomba:', 796 label: 'Bomba:',
797 valor: datos.bomba ? 'Si' : 'No' 797 valor: datos.bomba ? 'Si' : 'No'
798 }); 798 });
799 $scope.$broadcast('addCabecera',{ 799 $scope.$broadcast('addCabecera',{
800 label: 'Kilometros:', 800 label: 'Kilometros:',
801 valor: datos.kilometros 801 valor: datos.kilometros
802 }); 802 });
803 }else { 803 }else {
804 $scope.$broadcast('removeCabecera', 'Bomba:'); 804 $scope.$broadcast('removeCabecera', 'Bomba:');
805 $scope.$broadcast('removeCabecera', 'Kilometros:'); 805 $scope.$broadcast('removeCabecera', 'Kilometros:');
806 $scope.remito.fob = false; 806 $scope.remito.fob = false;
807 $scope.remito.bomba = false; 807 $scope.remito.bomba = false;
808 $scope.remito.kilometros = null; 808 $scope.remito.kilometros = null;
809 } 809 }
810 }, function() { 810 }, function() {
811 811
812 } 812 }
813 ); 813 );
814 } 814 }
815 }; 815 };
816 816
817 $scope.seleccionarMoneda = function() { 817 $scope.seleccionarMoneda = function() {
818 if(varlidarRemitoFacturado()) { 818 if(varlidarRemitoFacturado()) {
819 var parametrosModal = { 819 var parametrosModal = {
820 titulo: 'Búsqueda de monedas', 820 titulo: 'Búsqueda de monedas',
821 query: '/moneda', 821 query: '/moneda',
822 columnas: [ 822 columnas: [
823 { 823 {
824 propiedad: 'DETALLE', 824 propiedad: 'DETALLE',
825 nombre: 'Nombre' 825 nombre: 'Nombre'
826 }, 826 },
827 { 827 {
828 propiedad: 'SIMBOLO', 828 propiedad: 'SIMBOLO',
829 nombre: 'Símbolo' 829 nombre: 'Símbolo'
830 } 830 }
831 ], 831 ],
832 size: 'md' 832 size: 'md'
833 }; 833 };
834 focaModalService.modal(parametrosModal).then( 834 focaModalService.modal(parametrosModal).then(
835 function(moneda) { 835 function(moneda) {
836 $scope.abrirModalCotizacion(moneda); 836 $scope.abrirModalCotizacion(moneda);
837 }, function() { 837 }, function() {
838 838
839 } 839 }
840 ); 840 );
841 } 841 }
842 }; 842 };
843 843
844 $scope.seleccionarObservaciones = function() { 844 $scope.seleccionarObservaciones = function() {
845 focaModalService 845 focaModalService
846 .prompt('Ingrese observaciones', $scope.remito.observaciones, true, true) 846 .prompt('Ingrese observaciones', $scope.remito.observaciones, true, true)
847 .then(function(observaciones) { 847 .then(function(observaciones) {
848 $scope.remito.observaciones = observaciones; 848 $scope.remito.observaciones = observaciones;
849 }); 849 });
850 }; 850 };
851 851
852 $scope.abrirModalCotizacion = function(moneda) { 852 $scope.abrirModalCotizacion = function(moneda) {
853 var modalInstance = $uibModal.open( 853 var modalInstance = $uibModal.open(
854 { 854 {
855 ariaLabelledBy: 'Busqueda de Cotización', 855 ariaLabelledBy: 'Busqueda de Cotización',
856 templateUrl: 'modal-cotizacion.html', 856 templateUrl: 'modal-cotizacion.html',
857 controller: 'focaModalCotizacionController', 857 controller: 'focaModalCotizacionController',
858 size: 'lg', 858 size: 'lg',
859 resolve: {idMoneda: function() {return moneda.ID;}} 859 resolve: {idMoneda: function() {return moneda.ID;}}
860 } 860 }
861 ); 861 );
862 modalInstance.result.then( 862 modalInstance.result.then(
863 function(cotizacion) { 863 function(cotizacion) {
864 var articulosTablaTemp = $scope.articulosTabla; 864 var articulosTablaTemp = $scope.articulosTabla;
865 for(var i = 0; i < articulosTablaTemp.length; i++) { 865 for(var i = 0; i < articulosTablaTemp.length; i++) {
866 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * 866 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio *
867 $scope.remito.cotizacion.COTIZACION; 867 $scope.remito.cotizacion.COTIZACION;
868 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / 868 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio /
869 cotizacion.COTIZACION; 869 cotizacion.COTIZACION;
870 } 870 }
871 $scope.articulosTabla = articulosTablaTemp; 871 $scope.articulosTabla = articulosTablaTemp;
872 $scope.remito.moneda = moneda; 872 $scope.remito.moneda = moneda;
873 $scope.remito.cotizacion = cotizacion; 873 $scope.remito.cotizacion = cotizacion;
874 if(moneda.DETALLE === 'PESOS ARGENTINOS') { 874 if(moneda.DETALLE === 'PESOS ARGENTINOS') {
875 $scope.$broadcast('removeCabecera', 'Moneda:'); 875 $scope.$broadcast('removeCabecera', 'Moneda:');
876 $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); 876 $scope.$broadcast('removeCabecera', 'Fecha cotizacion:');
877 $scope.$broadcast('removeCabecera', 'Cotizacion:'); 877 $scope.$broadcast('removeCabecera', 'Cotizacion:');
878 }else { 878 }else {
879 $scope.$broadcast('addCabecera',{ 879 $scope.$broadcast('addCabecera',{
880 label: 'Moneda:', 880 label: 'Moneda:',
881 valor: moneda.DETALLE 881 valor: moneda.DETALLE
882 }); 882 });
883 $scope.$broadcast('addCabecera',{ 883 $scope.$broadcast('addCabecera',{
884 label: 'Fecha cotizacion:', 884 label: 'Fecha cotizacion:',
885 valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') 885 valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy')
886 }); 886 });
887 $scope.$broadcast('addCabecera',{ 887 $scope.$broadcast('addCabecera',{
888 label: 'Cotizacion:', 888 label: 'Cotizacion:',
889 valor: $filter('number')(cotizacion.COTIZACION, '2') 889 valor: $filter('number')(cotizacion.COTIZACION, '2')
890 }); 890 });
891 } 891 }
892 }, function() { 892 }, function() {
893 893
894 } 894 }
895 ); 895 );
896 }; 896 };
897 897
898 $scope.agregarATabla = function(key) { 898 $scope.agregarATabla = function(key) {
899 if(key === 13) { 899 if(key === 13) {
900 if($scope.articuloACargar.cantidad === undefined || 900 if($scope.articuloACargar.cantidad === undefined ||
901 $scope.articuloACargar.cantidad === 0 || 901 $scope.articuloACargar.cantidad === 0 ||
902 $scope.articuloACargar.cantidad === null ) { 902 $scope.articuloACargar.cantidad === null ) {
903 focaModalService.alert('El valor debe ser al menos 1'); 903 focaModalService.alert('El valor debe ser al menos 1');
904 return; 904 return;
905 } 905 }
906 delete $scope.articuloACargar.sectorCodigo; 906 delete $scope.articuloACargar.sectorCodigo;
907 $scope.articulosTabla.push($scope.articuloACargar); 907 $scope.articulosTabla.push($scope.articuloACargar);
908 $scope.cargando = true; 908 $scope.cargando = true;
909 } 909 }
910 }; 910 };
911 911
912 $scope.quitarArticulo = function(key) { 912 $scope.quitarArticulo = function(key) {
913 $scope.articulosTabla.splice(key, 1); 913 $scope.articulosTabla.splice(key, 1);
914 }; 914 };
915 915
916 $scope.editarArticulo = function(key, articulo) { 916 $scope.editarArticulo = function(key, articulo) {
917 if(key === 13) { 917 if(key === 13) {
918 if(articulo.cantidad === null || articulo.cantidad === 0 || 918 if(articulo.cantidad === null || articulo.cantidad === 0 ||
919 articulo.cantidad === undefined) { 919 articulo.cantidad === undefined) {
920 focaModalService.alert('El valor debe ser al menos 1'); 920 focaModalService.alert('El valor debe ser al menos 1');
921 return; 921 return;
922 } 922 }
923 articulo.editCantidad = false; 923 articulo.editCantidad = false;
924 articulo.editPrecio = false; 924 articulo.editPrecio = false;
925 } 925 }
926 }; 926 };
927 927
928 $scope.cambioEdit = function(articulo, propiedad) { 928 $scope.cambioEdit = function(articulo, propiedad) {
929 if(propiedad === 'cantidad') { 929 if(propiedad === 'cantidad') {
930 articulo.editCantidad = true; 930 articulo.editCantidad = true;
931 }else if(propiedad === 'precio') { 931 }else if(propiedad === 'precio') {
932 articulo.editPrecio = true; 932 articulo.editPrecio = true;
933 } 933 }
934 }; 934 };
935 935
936 $scope.limpiarFlete = function() { 936 $scope.limpiarFlete = function() {
937 $scope.remito.fleteNombre = ''; 937 $scope.remito.fleteNombre = '';
938 $scope.remito.chofer = ''; 938 $scope.remito.chofer = '';
939 $scope.remito.vehiculo = ''; 939 $scope.remito.vehiculo = '';
940 $scope.remito.kilometros = ''; 940 $scope.remito.kilometros = '';
941 $scope.remito.costoUnitarioKmFlete = ''; 941 $scope.remito.costoUnitarioKmFlete = '';
942 $scope.choferes = ''; 942 $scope.choferes = '';
943 $scope.vehiculos = ''; 943 $scope.vehiculos = '';
944 }; 944 };
945 945
946 $scope.limpiarPantalla = function() { 946 $scope.limpiarPantalla = function() {
947 $scope.limpiarFlete(); 947 $scope.limpiarFlete();
948 $scope.remito.flete = '0'; 948 $scope.remito.flete = '0';
949 $scope.remito.bomba = '0'; 949 $scope.remito.bomba = '0';
950 $scope.remito.precioCondicion = ''; 950 $scope.remito.precioCondicion = '';
951 $scope.articulosTabla = []; 951 $scope.articulosTabla = [];
952 $scope.remito.vendedor.nombre = ''; 952 $scope.remito.vendedor.nombre = '';
953 $scope.remito.cliente = {nombre: ''}; 953 $scope.remito.cliente = {nombre: ''};
954 $scope.remito.domicilio = {dom: ''}; 954 $scope.remito.domicilio = {dom: ''};
955 $scope.domiciliosCliente = []; 955 $scope.domiciliosCliente = [];
956 }; 956 };
957 957
958 $scope.resetFilter = function() { 958 $scope.resetFilter = function() {
959 $scope.articuloACargar = {}; 959 $scope.articuloACargar = {};
960 $scope.cargando = true; 960 $scope.cargando = true;
961 }; 961 };
962 //Recibe aviso si el teclado está en uso 962 //Recibe aviso si el teclado está en uso
963 $rootScope.$on('usarTeclado', function(event, data) { 963 $rootScope.$on('usarTeclado', function(event, data) {
964 if(data) { 964 if(data) {
965 $scope.mostrarTeclado = true; 965 $scope.mostrarTeclado = true;
966 return; 966 return;
967 } 967 }
968 $scope.mostrarTeclado = false; 968 $scope.mostrarTeclado = false;
969 }); 969 });
970 970
971 $scope.selectFocus = function($event) { 971 $scope.selectFocus = function($event) {
972 // Si el teclado esta en uso no selecciona el valor 972 // Si el teclado esta en uso no selecciona el valor
973 if($scope.mostrarTeclado) { 973 if($scope.mostrarTeclado) {
974 return; 974 return;
975 } 975 }
976 $event.target.select(); 976 $event.target.select();
977 }; 977 };
978 978
979 function addArrayCabecera(array) { 979 function addArrayCabecera(array) {
980 for(var i = 0; i < array.length; i++) { 980 for(var i = 0; i < array.length; i++) {
981 $scope.$broadcast('addCabecera',{ 981 $scope.$broadcast('addCabecera',{
982 label: array[i].label, 982 label: array[i].label,
983 valor: array[i].valor 983 valor: array[i].valor
984 }); 984 });
985 } 985 }
986 } 986 }
987 987
988 function rellenar(relleno, longitud) { 988 function rellenar(relleno, longitud) {
989 relleno = '' + relleno; 989 relleno = '' + relleno;
990 while (relleno.length < longitud) { 990 while (relleno.length < longitud) {
991 relleno = '0' + relleno; 991 relleno = '0' + relleno;
992 } 992 }
993 993
994 return relleno; 994 return relleno;
995 } 995 }
996 996
997 function varlidarRemitoFacturado() { 997 function varlidarRemitoFacturado() {
998 if($scope.remito.estado !== 5) { 998 if($scope.remito.estado !== 5) {
999 return true; 999 return true;
1000 }else { 1000 }else {
1001 focaModalService.alert('No se puede editar un remito facturado'); 1001 focaModalService.alert('No se puede editar un remito facturado');
1002 return false(); 1002 return false();
1003 } 1003 }
1004 } 1004 }
1005 1005
1006 function salir() { 1006 function salir() {
1007 var confirmacion = false; 1007 var confirmacion = false;
1008 1008
1009 angular.forEach($scope.inicial, function(valor, key) { 1009 angular.forEach($scope.inicial, function(valor, key) {
1010 if (!angular.equals($scope[key], $scope.inicial[key])) { 1010 if (!angular.equals($scope[key], $scope.inicial[key])) {
1011 confirmacion = true; 1011 confirmacion = true;
1012 } 1012 }
1013 }); 1013 });
1014 1014
1015 if (confirmacion) { 1015 if (confirmacion) {
1016 focaModalService.confirm( 1016 focaModalService.confirm(
1017 '¿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.'
1018 ).then(function(data) { 1018 ).then(function(data) {
1019 if (data) { 1019 if (data) {
1020 $location.path('/'); 1020 $location.path('/');
1021 } 1021 }
1022 }); 1022 });
1023 } else { 1023 } else {
1024 $location.path('/'); 1024 $location.path('/');
1025 } 1025 }
1026 } 1026 }
1027 1027
1028 function enableObservaciones(val) { 1028 function enableObservaciones(val) {
1029 var boton = $scope.botonera.filter(function(botonObs) { 1029 var boton = $scope.botonera.filter(function(botonObs) {
1030 return botonObs.label === 'Observaciones'; 1030 return botonObs.label === 'Observaciones';
1031 }); 1031 });
1032 1032
1033 boton[0].disable = !val; 1033 boton[0].disable = !val;
1034 } 1034 }
1035 } 1035 }
1036 ]); 1036 ]);
1037 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',
7 '$filter', 6 '$filter',
8 'parametros', 7 'parametros',
9 'FileSaver', 8 'FileSaver',
10 'Blob', 9 'Blob',
11 function( 10 function(
12 $scope, $uibModalInstance, crearRemitoService, $window, $filter, 11 $scope, $uibModalInstance, crearRemitoService, $filter,
13 parametros, FileSaver, Blob 12 parametros, FileSaver, Blob
14 ) { 13 ) {
14 crearRemitoService.getRemitoById(parametros.idRemito).then(function(res) {
15
16 $scope.remito = res.data;
17 });
15 $scope.correoEnviado = false; 18 $scope.correoEnviado = false;
16 $scope.correoNoEnviado = false; 19 $scope.correoNoEnviado = false;
17 $scope.esperando = false; 20 $scope.esperando = false;
18 $scope.remito = parametros.remito;
19 21
20 $scope.aceptar = function() { 22 $scope.aceptar = function() {
21 $uibModalInstance.close(); 23 $uibModalInstance.close();
22 }; 24 };
23 25
24 $scope.imprimir = function () { 26 $scope.imprimir = function () {
27 $scope.esperando = true;
25 crearRemitoService.imprimirRemitoByIdRemito($scope.remito.id).then( 28 crearRemitoService.imprimirRemitoByIdRemito($scope.remito.id).then(
26 function(res) { 29 function(res) {
27 var data = new Blob([res.data], {type: 'application/pdf'}); 30 var data = new Blob([res.data], {type: 'application/pdf'});
28 31
29 FileSaver.saveAs( 32 FileSaver.saveAs(
30 data, 33 data,
31 $filter('comprobante')([ 34 'RE-R-' + $filter('comprobante')([
32 parametros.remito.sucursal, 35 $scope.remito.sucursal,
33 parametros.remito.numeroRemito 36 $scope.remito.numeroRemito
34 ]) + '.pdf' 37 ]) + '.pdf'
35 ); 38 );
39 $scope.esperando = false;
36 } 40 }
37 ); 41 );
38 }; 42 };
39 43
40 $scope.enviarCorreo = function(key) { 44 $scope.enviarCorreo = function(key) {
41 if(key !== 13) return; 45 if(key !== 13) return;
42 $scope.esperando = true; 46 $scope.esperando = true;
43 var options = { 47 var options = {
44 para: $scope.remito.cliente.MAIL, 48 para: $scope.remito.cliente.MAIL,
45 remito: $scope.remito.id 49 remito: $scope.remito.id
46 }; 50 };
47 51
48 crearRemitoService.enviarCorreo(options).then(function() { 52 crearRemitoService.enviarCorreo(options).then(function() {
49 $scope.correoEnviado = true; 53 $scope.correoEnviado = true;
50 $scope.esperando = false; 54 $scope.esperando = false;
51 }, function() { 55 }, function() {
52 $scope.esperando = false; 56 $scope.esperando = false;
53 $scope.correoNoEnviado = true; 57 $scope.correoNoEnviado = true;
54 }); 58 });
55 }; 59 };
56 } 60 }
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 getRemitoById: function(id) {
10 return $http.get(route + '/remito/obtener/' + id);
11 },
9 obtenerRemito: function() { 12 obtenerRemito: function() {
10 return $http.get(route +'/nota-pedido'); 13 return $http.get(route +'/nota-pedido');
11 }, 14 },
12 setRemito: function(remito) { 15 setRemito: function(remito) {
13 this.remito = remito; 16 this.remito = remito;
14 }, 17 },
15 clearRemito: function() { 18 clearRemito: function() {
16 this.remito = undefined; 19 this.remito = undefined;
17 }, 20 },
18 getRemito: function() { 21 getRemito: function() {
19 return this.remito; 22 return this.remito;
20 }, 23 },
21 getArticulosByIdRemito: function(id) { 24 getArticulosByIdRemito: function(id) {
22 return $http.get(route+'/articulos/nota-pedido/'+id); 25 return $http.get(route+'/articulos/nota-pedido/'+id);
23 }, 26 },
24 crearArticulosParaRemito: function(articuloRemito) { 27 crearArticulosParaRemito: function(articuloRemito) {
25 return $http.post(route + '/articulos/remito', 28 return $http.post(route + '/articulos/remito',
26 {articuloRemito: articuloRemito}); 29 {articuloRemito: articuloRemito});
27 }, 30 },
28 getDomiciliosByIdRemito: function(id) { 31 getDomiciliosByIdRemito: function(id) {
29 return $http.get(route +'/nota-pedido/'+id+'/domicilios'); 32 return $http.get(route +'/nota-pedido/'+id+'/domicilios');
30 }, 33 },
31 getDomiciliosByIdCliente: function(id) { 34 getDomiciliosByIdCliente: function(id) {
32 var idTipoEntrega = 2;//Solo traigo los domicilios que tienen tipo 2 (tipo entrega) 35 var idTipoEntrega = 2;//Solo traigo los domicilios que tienen tipo 2 (tipo entrega)
33 return $http.get(route + '/domicilio/tipo/' + idTipoEntrega + '/cliente/' + id ); 36 return $http.get(route + '/domicilio/tipo/' + idTipoEntrega + '/cliente/' + id );
34 }, 37 },
35 getPrecioCondicion: function() { 38 getPrecioCondicion: function() {
36 return $http.get(route + '/precio-condicion'); 39 return $http.get(route + '/precio-condicion');
37 }, 40 },
38 getPrecioCondicionById: function(id) { 41 getPrecioCondicionById: function(id) {
39 return $http.get(route + '/precio-condicion/' + id); 42 return $http.get(route + '/precio-condicion/' + id);
40 }, 43 },
41 getPlazoPagoByPrecioCondicion: function(id) { 44 getPlazoPagoByPrecioCondicion: function(id) {
42 return $http.get(route + '/plazo-pago/precio-condicion/'+ id); 45 return $http.get(route + '/plazo-pago/precio-condicion/'+ id);
43 }, 46 },
44 crearFlete: function(flete) { 47 crearFlete: function(flete) {
45 return $http.post(route + '/flete', {flete : flete}); 48 return $http.post(route + '/flete', {flete : flete});
46 }, 49 },
47 crearPlazosParaRemito: function(plazos) { 50 crearPlazosParaRemito: function(plazos) {
48 return $http.post(route + '/plazo-pago/remito', plazos); 51 return $http.post(route + '/plazo-pago/remito', plazos);
49 }, 52 },
50 getCotizacionByIdMoneda: function(id) { 53 getCotizacionByIdMoneda: function(id) {
51 return $http.get(route + '/moneda/' + id); 54 return $http.get(route + '/moneda/' + id);
52 }, 55 },
53 crearEstadoParaRemito: function(estado) { 56 crearEstadoParaRemito: function(estado) {
54 return $http.post(route + '/estado', {estado: estado}); 57 return $http.post(route + '/estado', {estado: estado});
55 }, 58 },
56 getNumeroRemito: function() { 59 getNumeroRemito: function() {
57 return $http.get(route + '/remito/numero-siguiente'); 60 return $http.get(route + '/remito/numero-siguiente');
58 }, 61 },
59 imprimirRemitoByIdRemito: function(idRemito, original) { 62 imprimirRemitoByIdRemito: function(idRemito, original) {
60 var tipo = original ? '/original' : ''; 63 var tipo = original ? '/original' : '';
61 return $http.get(route + '/remito/comprobante/' + idRemito + tipo, { 64 return $http.get(route + '/remito/comprobante/' + idRemito + tipo, {
62 responseType: 'arraybuffer' 65 responseType: 'arraybuffer'
63 }); 66 });
64 }, 67 },
65 getPuntosDescargaByClienDom: function(idDomicilio, idCliente) { 68 getPuntosDescargaByClienDom: function(idDomicilio, idCliente) {
66 return $http.get(API_ENDPOINT.URL + '/punto-descarga/' + 69 return $http.get(API_ENDPOINT.URL + '/punto-descarga/' +
67 idDomicilio + '/' + idCliente); 70 idDomicilio + '/' + idCliente);
68 }, 71 },
69 enviarCorreo: function(options) { 72 enviarCorreo: function(options) {
70 return $http.post(API_ENDPOINT.URL + '/remito/mail', options); 73 return $http.post(API_ENDPOINT.URL + '/remito/mail', options);
71 }, 74 },
72 getBotonera: function() { 75 getBotonera: function() {
73 return [ 76 return [
74 { 77 {
75 label: 'Nota pedido', 78 label: 'Nota pedido',
76 image: 'notaDePedido.png' 79 image: 'notaDePedido.png'
77 }, 80 },
78 { 81 {
79 label: 'Vendedor', 82 label: 'Vendedor',
80 image: 'vendedor.png' 83 image: 'vendedor.png'
81 }, 84 },
82 { 85 {
83 label: 'Cliente', 86 label: 'Cliente',
84 image: 'cliente.png' 87 image: 'cliente.png'
85 }, 88 },
86 { 89 {
87 label: 'Proveedor', 90 label: 'Proveedor',
88 image: 'proveedor.png' 91 image: 'proveedor.png'
89 }, 92 },
90 { 93 {
91 label: 'Moneda', 94 label: 'Moneda',
92 image: 'moneda.png' 95 image: 'moneda.png'
93 }, 96 },
94 { 97 {
95 label: 'Precios y condiciones', 98 label: 'Precios y condiciones',
96 image: 'precios-condiciones.png' 99 image: 'precios-condiciones.png'
97 }, 100 },
98 { 101 {
99 label: 'Flete', 102 label: 'Flete',
100 image: 'flete.png' 103 image: 'flete.png'
101 }, 104 },
102 { 105 {
103 label: 'Productos', 106 label: 'Productos',
104 image: 'productos.png' 107 image: 'productos.png'
105 }, 108 },
106 { 109 {
107 label: 'Observaciones', 110 label: 'Observaciones',
108 image: 'productos.png', 111 image: 'productos.png',
109 disable: true 112 disable: true
110 } 113 }
111 ]; 114 ];
112 } 115 }
113 }; 116 };
114 }]); 117 }]);
115 118
src/views/remito-comprobante.html
1 <div class="modal-header"> 1 <div class="modal-header">
2 <h5>Comprobante de remito Nº 2 <h5>Comprobante de remito Nº
3 <span 3 <span
4 ng-bind="[remito.numeroRemito, remito.sucursal] | comprobante"> 4 ng-bind="[remito.sucursal, remito.numeroRemito] | comprobante">
5 </span> 5 </span>
6 </h5> 6 </h5>
7 </div> 7 </div>
8 <div class="modal-body"> 8 <div class="modal-body">
9 <div class="col-12"> 9 <div class="col-12">
10 <label 10 <label
11 class="col-12 bg-success text-white" 11 class="col-12 bg-success text-white"
12 ng-show="correoEnviado">Correo enviado con éxito</label> 12 ng-show="correoEnviado">Correo enviado con éxito</label>
13 <label 13 <label
14 class="col-12 bg-danger text-white" 14 class="col-12 bg-danger text-white"
15 ng-show="correoNoEnviado">Hubo un error al enviar el correo</label> 15 ng-show="correoNoEnviado">Hubo un error al enviar el correo</label>
16 <label>Enviar correo a </label> 16 <label>Enviar correo a </label>
17 <input 17 <input
18 class="form-control" 18 class="form-control"
19 ng-model="remito.cliente.MAIL" 19 ng-model="remito.cliente.MAIL"
20 ng-click="enviarCorreo($event.keyCode)"/> 20 ng-click="enviarCorreo($event.keyCode)"/>
21 </div> 21 </div>
22 </div> 22 </div>
23 <div class="modal-footer"> 23 <div class="modal-footer">
24 <button 24 <button
25 type="button" 25 type="button"
26 class="btn btn-info" 26 class="btn btn-info"
27 ng-click="imprimir()" 27 ng-click="imprimir()"
28 ladda="esperando" 28 ladda="esperando"
29 >Imprimir</button> 29 >Imprimir</button>
30 <button 30 <button
31 type="button" 31 type="button"
32 class="btn btn-primary" 32 class="btn btn-primary"
33 ng-click="aceptar()" 33 ng-click="aceptar()"
34 ladda="esperando" 34 ladda="esperando"
35 >Aceptar</button> 35 >Aceptar</button>
36 <button 36 <button
37 type="button" 37 type="button"
38 class="btn btn-primary" 38 class="btn btn-primary"
39 ng-click="enviarCorreo(13)" 39 ng-click="enviarCorreo(13)"
40 ladda="esperando" 40 ladda="esperando"
41 >Enviar</button> 41 >Enviar</button>
42 </div> 42 </div>
43 43