Commit 06ab7ed93bd41f3cc9ec67ae93ac6f0a3f3b871a

Authored by Eric Fernandez
1 parent bff7194b46
Exists in master and in 1 other branch develop

espacio

Showing 1 changed file with 1 additions and 1 deletions   Show diff stats
src/js/controller.js
1 angular.module('focaCrearRemito') .controller('remitoController', 1 angular.module('focaCrearRemito') .controller('remitoController',
2 [ 2 [
3 '$scope', '$uibModal', '$location', '$filter', 'crearRemitoService', 3 '$scope', '$uibModal', '$location', '$filter', 'crearRemitoService',
4 'focaModalService', 'remitoBusinessService', 4 'focaModalService', 'remitoBusinessService',
5 function( 5 function(
6 $scope, $uibModal, $location, $filter, crearRemitoService, focaModalService, 6 $scope, $uibModal, $location, $filter, crearRemitoService, focaModalService,
7 remitoBusinessService) 7 remitoBusinessService)
8 { 8 {
9 $scope.botonera = [ 9 $scope.botonera = [
10 {texto: 'Nota Pedido', accion: function() { 10 {texto: 'Nota Pedido', accion: function() {
11 varlidarRemitoFacturado($scope.seleccionarNotaPedido);}}, 11 varlidarRemitoFacturado($scope.seleccionarNotaPedido);}},
12 {texto: 'Vendedor', accion: function() { 12 {texto: 'Vendedor', accion: function() {
13 varlidarRemitoFacturado($scope.seleccionarVendedor);}}, 13 varlidarRemitoFacturado($scope.seleccionarVendedor);}},
14 {texto: 'Cliente', accion: function() { 14 {texto: 'Cliente', accion: function() {
15 varlidarRemitoFacturado($scope.seleccionarCliente);}}, 15 varlidarRemitoFacturado($scope.seleccionarCliente);}},
16 {texto: 'Proveedor', accion: function() { 16 {texto: 'Proveedor', accion: function() {
17 varlidarRemitoFacturado($scope.seleccionarProveedor);}}, 17 varlidarRemitoFacturado($scope.seleccionarProveedor);}},
18 {texto: 'Moneda', accion: function() { 18 {texto: 'Moneda', accion: function() {
19 varlidarRemitoFacturado($scope.abrirModalMoneda);}}, 19 varlidarRemitoFacturado($scope.abrirModalMoneda);}},
20 {texto: 'Precios y condiciones', accion: function() { 20 {texto: 'Precios y condiciones', accion: function() {
21 varlidarRemitoFacturado($scope.abrirModalListaPrecio);}}, 21 varlidarRemitoFacturado($scope.abrirModalListaPrecio);}},
22 {texto: 'Flete', accion: function() { 22 {texto: 'Flete', accion: function() {
23 varlidarRemitoFacturado($scope.abrirModalFlete);}}, 23 varlidarRemitoFacturado($scope.abrirModalFlete);}},
24 {texto: '', accion: function() {}} 24 {texto: '', accion: function() {}}
25 ]; 25 ];
26 $scope.datepickerAbierto = false; 26 $scope.datepickerAbierto = false;
27 27
28 $scope.show = false; 28 $scope.show = false;
29 $scope.cargando = true; 29 $scope.cargando = true;
30 $scope.dateOptions = { 30 $scope.dateOptions = {
31 maxDate: new Date(), 31 maxDate: new Date(),
32 minDate: new Date(2010, 0, 1) 32 minDate: new Date(2010, 0, 1)
33 }; 33 };
34 34
35 $scope.remito = { 35 $scope.remito = {
36 id: 0, 36 id: 0,
37 estado: 0, 37 estado: 0,
38 vendedor: {}, 38 vendedor: {},
39 cliente: {}, 39 cliente: {},
40 proveedor: {}, 40 proveedor: {},
41 domicilio: {dom: ''}, 41 domicilio: {dom: ''},
42 moneda: {}, 42 moneda: {},
43 cotizacion: {} 43 cotizacion: {}
44 }; 44 };
45 45
46 $scope.notaPedido = { 46 $scope.notaPedido = {
47 id: 0 47 id: 0
48 }; 48 };
49 var monedaPorDefecto; 49 var monedaPorDefecto;
50 //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' 50 //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]'
51 crearRemitoService.getCotizacionByIdMoneda(1).then(function(res) { 51 crearRemitoService.getCotizacionByIdMoneda(1).then(function(res) {
52 monedaPorDefecto = res.data[0]; 52 monedaPorDefecto = res.data[0];
53 addCabecera('Moneda:', monedaPorDefecto.DETALLE); 53 addCabecera('Moneda:', monedaPorDefecto.DETALLE);
54 addCabecera('Fecha cotizacion:', 54 addCabecera('Fecha cotizacion:',
55 new Date(monedaPorDefecto.cotizaciones[0].FECHA).toLocaleDateString()); 55 new Date(monedaPorDefecto.cotizaciones[0].FECHA).toLocaleDateString());
56 addCabecera('Cotizacion:', monedaPorDefecto.cotizaciones[0].VENDEDOR); 56 addCabecera('Cotizacion:', monedaPorDefecto.cotizaciones[0].VENDEDOR);
57 $scope.remito.moneda = monedaPorDefecto; 57 $scope.remito.moneda = monedaPorDefecto;
58 $scope.remito.cotizacion = monedaPorDefecto.cotizaciones[0]; 58 $scope.remito.cotizacion = monedaPorDefecto.cotizaciones[0];
59 }); 59 });
60 60
61 $scope.cabecera = []; 61 $scope.cabecera = [];
62 $scope.showCabecera = true; 62 $scope.showCabecera = true;
63 63
64 $scope.now = new Date(); 64 $scope.now = new Date();
65 $scope.puntoVenta = rellenar(0, 4); 65 $scope.puntoVenta = rellenar(0, 4);
66 $scope.comprobante = rellenar(0, 8); 66 $scope.comprobante = rellenar(0, 8);
67 67
68 $scope.articulosTabla = []; 68 $scope.articulosTabla = [];
69 $scope.idLista = undefined; 69 $scope.idLista = undefined;
70 70
71 crearRemitoService.getPrecioCondicion().then( 71 crearRemitoService.getPrecioCondicion().then(
72 function(res) { 72 function(res) {
73 $scope.precioCondiciones = res.data; 73 $scope.precioCondiciones = res.data;
74 } 74 }
75 ); 75 );
76 76
77 crearRemitoService.getNumeroRemito().then( 77 crearRemitoService.getNumeroRemito().then(
78 function(res) { 78 function(res) {
79 $scope.puntoVenta = rellenar(res.data.sucursal, 4); 79 $scope.puntoVenta = rellenar(res.data.sucursal, 4);
80 $scope.comprobante = rellenar(res.data.numeroRemito, 8); 80 $scope.comprobante = rellenar(res.data.numeroRemito, 8);
81 }, 81 },
82 function(err) { 82 function(err) {
83 focaModalService.alert('La terminal no esta configurada correctamente'); 83 focaModalService.alert('La terminal no esta configurada correctamente');
84 console.info(err); 84 console.info(err);
85 } 85 }
86 ); 86 );
87 87
88 $scope.seleccionarNotaPedido = function() { 88 $scope.seleccionarNotaPedido = function() {
89 var modalInstance = $uibModal.open( 89 var modalInstance = $uibModal.open(
90 { 90 {
91 ariaLabelledBy: 'Busqueda de Nota de Pedido', 91 ariaLabelledBy: 'Busqueda de Nota de Pedido',
92 templateUrl: 'foca-modal-nota-pedido.html', 92 templateUrl: 'foca-modal-nota-pedido.html',
93 controller: 'focaModalNotaPedidoController', 93 controller: 'focaModalNotaPedidoController',
94 size: 'lg', 94 size: 'lg',
95 resolve: { 95 resolve: {
96 usadoPor: function() { 96 usadoPor: function() {
97 return 'remito'; 97 return 'remito';
98 } 98 }
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 removeCabecera('Bomba:'); 106 removeCabecera('Bomba:');
107 removeCabecera('Kilometros:'); 107 removeCabecera('Kilometros:');
108 var cabeceras = [ 108 var cabeceras = [
109 { 109 {
110 label: 'Moneda:', 110 label: 'Moneda:',
111 valor: notaPedido.cotizacion[0].moneda[0].DETALLE 111 valor: notaPedido.cotizacion[0].moneda[0].DETALLE
112 }, 112 },
113 { 113 {
114 label: 'Fecha cotizacion:', 114 label: 'Fecha cotizacion:',
115 valor: $filter('date')(notaPedido.cotizacion[0].FECHA, 115 valor: $filter('date')(notaPedido.cotizacion[0].FECHA,
116 'dd/MM/yyyy') 116 'dd/MM/yyyy')
117 }, 117 },
118 { 118 {
119 label: 'Cotizacion:', 119 label: 'Cotizacion:',
120 valor: notaPedido.cotizacion[0].VENDEDOR 120 valor: notaPedido.cotizacion[0].VENDEDOR
121 }, 121 },
122 { 122 {
123 label: 'Cliente:', 123 label: 'Cliente:',
124 valor: notaPedido.cliente[0].NOM 124 valor: notaPedido.cliente[0].NOM
125 }, 125 },
126 { 126 {
127 label: 'Domicilio:', 127 label: 'Domicilio:',
128 valor: notaPedido.domicilioStamp 128 valor: notaPedido.domicilioStamp
129 }, 129 },
130 { 130 {
131 label: 'Vendedor:', 131 label: 'Vendedor:',
132 valor: notaPedido.vendedor[0].NomVen 132 valor: notaPedido.vendedor[0].NomVen
133 }, 133 },
134 { 134 {
135 label: 'Proveedor:', 135 label: 'Proveedor:',
136 valor: notaPedido.proveedor[0].NOM 136 valor: notaPedido.proveedor[0].NOM
137 }, 137 },
138 { 138 {
139 label: 'Precio condicion:', 139 label: 'Precio condicion:',
140 valor: valorPrecioCondicion() + ' ' + 140 valor: valorPrecioCondicion() + ' ' +
141 remitoBusinessService.plazoToString(notaPedido.plazoPago) 141 remitoBusinessService.plazoToString(notaPedido.plazoPago)
142 }, 142 },
143 { 143 {
144 label: 'Flete:', 144 label: 'Flete:',
145 valor: notaPedido.fob === 1 ? 'FOB' : ( 145 valor: notaPedido.fob === 1 ? 'FOB' : (
146 notaPedido.flete === 1 ? 'Si' : 'No') 146 notaPedido.flete === 1 ? 'Si' : 'No')
147 } 147 }
148 ]; 148 ];
149 149
150 function valorPrecioCondicion() { 150 function valorPrecioCondicion() {
151 if(notaPedido.idPrecioCondicion > 0) { 151 if(notaPedido.idPrecioCondicion > 0) {
152 return notaPedido.precioCondicion[0].nombre; 152 return notaPedido.precioCondicion[0].nombre;
153 } else { 153 } else {
154 return 'Ingreso Manual'; 154 return 'Ingreso Manual';
155 } 155 }
156 } 156 }
157 157
158 if(notaPedido.flete === 1) { 158 if(notaPedido.flete === 1) {
159 var cabeceraBomba = { 159 var cabeceraBomba = {
160 label: 'Bomba:', 160 label: 'Bomba:',
161 valor: notaPedido.bomba === 1 ? 'Si' : 'No' 161 valor: notaPedido.bomba === 1 ? 'Si' : 'No'
162 }; 162 };
163 if(notaPedido.kilometros) { 163 if(notaPedido.kilometros) {
164 var cabeceraKilometros = { 164 var cabeceraKilometros = {
165 label: 'Kilometros:', 165 label: 'Kilometros:',
166 valor: notaPedido.kilometros 166 valor: notaPedido.kilometros
167 }; 167 };
168 cabeceras.push(cabeceraKilometros); 168 cabeceras.push(cabeceraKilometros);
169 } 169 }
170 cabeceras.push(cabeceraBomba); 170 cabeceras.push(cabeceraBomba);
171 } 171 }
172 172
173 for (var i = notaPedido.articulosNotaPedido.length - 1; i >= 0; i--) { 173 for (var i = notaPedido.articulosNotaPedido.length - 1; i >= 0; i--) {
174 notaPedido.articulosNotaPedido[i].id = 0; 174 notaPedido.articulosNotaPedido[i].id = 0;
175 } 175 }
176 176
177 $scope.articulosTabla = notaPedido.articulosNotaPedido; 177 $scope.articulosTabla = notaPedido.articulosNotaPedido;
178 remitoBusinessService.calcularArticulos($scope.articulosTabla, 178 remitoBusinessService.calcularArticulos($scope.articulosTabla,
179 notaPedido.cotizacion[0].VENDEDOR); 179 notaPedido.cotizacion[0].VENDEDOR);
180 180
181 if(notaPedido.precioCondicion.length > 0) { 181 if(notaPedido.precioCondicion.length > 0) {
182 $scope.idLista = notaPedido.precioCondicion[0].idListaPrecio; 182 $scope.idLista = notaPedido.precioCondicion[0].idListaPrecio;
183 } else { 183 } else {
184 $scope.idLista = -1; 184 $scope.idLista = -1;
185 } 185 }
186 186
187 delete notaPedido.id; 187 delete notaPedido.id;
188 $scope.remito = notaPedido; 188 $scope.remito = notaPedido;
189 $scope.remito.vendedor = notaPedido.vendedor[0]; 189 $scope.remito.vendedor = notaPedido.vendedor[0];
190 $scope.remito.cliente = notaPedido.cliente[0]; 190 $scope.remito.cliente = notaPedido.cliente[0];
191 $scope.remito.proveedor = notaPedido.proveedor[0]; 191 $scope.remito.proveedor = notaPedido.proveedor[0];
192 $scope.remito.moneda = notaPedido.cotizacion[0].moneda[0]; 192 $scope.remito.moneda = notaPedido.cotizacion[0].moneda[0];
193 $scope.remito.cotizacion = notaPedido.cotizacion[0]; 193 $scope.remito.cotizacion = notaPedido.cotizacion[0];
194 addArrayCabecera(cabeceras); 194 addArrayCabecera(cabeceras);
195 195
196 }, function() { 196 }, function() {
197 // funcion ejecutada cuando se cancela el modal 197 // funcion ejecutada cuando se cancela el modal
198 } 198 }
199 ); 199 );
200 }; 200 };
201 201
202 $scope.seleccionarRemito = function() { 202 $scope.seleccionarRemito = function() {
203 var modalInstance = $uibModal.open( 203 var modalInstance = $uibModal.open(
204 { 204 {
205 ariaLabelledBy: 'Busqueda de Remito', 205 ariaLabelledBy: 'Busqueda de Remito',
206 templateUrl: 'foca-modal-remito.html', 206 templateUrl: 'foca-modal-remito.html',
207 controller: 'focaModalRemitoController', 207 controller: 'focaModalRemitoController',
208 size: 'lg', 208 size: 'lg',
209 resolve: {usadoPor: function() {return 'remito';}} 209 resolve: {usadoPor: function() {return 'remito';}}
210 } 210 }
211 ); 211 );
212 modalInstance.result.then( 212 modalInstance.result.then(
213 function(remito) { 213 function(remito) {
214 //añado cabeceras 214 //añado cabeceras
215 removeCabecera('Moneda:'); 215 removeCabecera('Moneda:');
216 removeCabecera('Fecha cotizacion:'); 216 removeCabecera('Fecha cotizacion:');
217 removeCabecera('Cotizacion:'); 217 removeCabecera('Cotizacion:');
218 var cabeceras = [ 218 var cabeceras = [
219 { 219 {
220 label: 'Moneda:', 220 label: 'Moneda:',
221 valor: remito.cotizacion[0].moneda[0].DETALLE 221 valor: remito.cotizacion[0].moneda[0].DETALLE
222 }, 222 },
223 { 223 {
224 label: 'Fecha cotizacion:', 224 label: 'Fecha cotizacion:',
225 valor: $filter('date')(remito.cotizacion[0].FECHA, 225 valor: $filter('date')(remito.cotizacion[0].FECHA,
226 'dd/MM/yyyy') 226 'dd/MM/yyyy')
227 }, 227 },
228 { 228 {
229 label: 'Cotizacion:', 229 label: 'Cotizacion:',
230 valor: remito.cotizacion[0].VENDEDOR 230 valor: remito.cotizacion[0].VENDEDOR
231 }, 231 },
232 { 232 {
233 label: 'Cliente:', 233 label: 'Cliente:',
234 valor: remito.cliente[0].NOM 234 valor: remito.cliente[0].NOM
235 }, 235 },
236 { 236 {
237 label: 'Domicilio:', 237 label: 'Domicilio:',
238 valor: remito.domicilioStamp 238 valor: remito.domicilioStamp
239 }, 239 },
240 { 240 {
241 label: 'Vendedor:', 241 label: 'Vendedor:',
242 valor: remito.vendedor[0].NomVen 242 valor: remito.vendedor[0].NomVen
243 }, 243 },
244 { 244 {
245 label: 'Proveedor:', 245 label: 'Proveedor:',
246 valor: remito.proveedor[0].NOM 246 valor: remito.proveedor[0].NOM
247 }, 247 },
248 { 248 {
249 label: 'Flete:', 249 label: 'Flete:',
250 valor: remito.fob === 1 ? 'FOB' : ( 250 valor: remito.fob === 1 ? 'FOB' : (
251 remito.flete === 1 ? 'Si' : 'No') 251 remito.flete === 1 ? 'Si' : 'No')
252 }, 252 },
253 { 253 {
254 label: 'Precio condicion:', 254 label: 'Precio condicion:',
255 valor: valorPrecioCondicion() 255 valor: valorPrecioCondicion()
256 } 256 }
257 ]; 257 ];
258 //TO DO CUANDO MOSTRAR PLAZOS 258 //TO DO CUANDO MOSTRAR PLAZOS
259 function valorPrecioCondicion() { 259 function valorPrecioCondicion() {
260 if(remito.idPrecioCondicion > 0) { 260 if(remito.idPrecioCondicion > 0) {
261 return remito.precioCondicion[0].nombre; 261 return remito.precioCondicion[0].nombre;
262 } else { 262 } else {
263 return 'Ingreso Manual'; 263 return 'Ingreso Manual';
264 } 264 }
265 } 265 }
266 266
267 if(remito.flete === 1) { 267 if(remito.flete === 1) {
268 var cabeceraBomba = { 268 var cabeceraBomba = {
269 label: 'Bomba', 269 label: 'Bomba',
270 valor: remito.bomba === 1 ? 'Si' : 'No' 270 valor: remito.bomba === 1 ? 'Si' : 'No'
271 }; 271 };
272 if(remito.kilometros) { 272 if(remito.kilometros) {
273 var cabeceraKilometros = { 273 var cabeceraKilometros = {
274 label: 'Kilometros', 274 label: 'Kilometros',
275 valor: remito.kilometros 275 valor: remito.kilometros
276 }; 276 };
277 cabeceras.push(cabeceraKilometros); 277 cabeceras.push(cabeceraKilometros);
278 } 278 }
279 cabeceras.push(cabeceraBomba); 279 cabeceras.push(cabeceraBomba);
280 } 280 }
281 $scope.articulosTabla = remito.articulosRemito; 281 $scope.articulosTabla = remito.articulosRemito;
282 remitoBusinessService.calcularArticulos($scope.articulosTabla, 282 remitoBusinessService.calcularArticulos($scope.articulosTabla,
283 remito.cotizacion[0].VENDEDOR); 283 remito.cotizacion[0].VENDEDOR);
284 if(remito.precioCondicion.length > 0) { 284 if(remito.precioCondicion.length > 0) {
285 $scope.idLista = remito.precioCondicion[0].idListaPrecio; 285 $scope.idLista = remito.precioCondicion[0].idListaPrecio;
286 } else { 286 } else {
287 $scope.idLista = -1; 287 $scope.idLista = -1;
288 } 288 }
289 $scope.comprobante = rellenar(remito.numeroRemito, 8); 289 $scope.comprobante = rellenar(remito.numeroRemito, 8);
290 $scope.remito = remito; 290 $scope.remito = remito;
291 $scope.remito.vendedor = remito.vendedor[0]; 291 $scope.remito.vendedor = remito.vendedor[0];
292 $scope.remito.cliente = remito.cliente[0]; 292 $scope.remito.cliente = remito.cliente[0];
293 $scope.remito.proveedor = remito.proveedor[0]; 293 $scope.remito.proveedor = remito.proveedor[0];
294 $scope.remito.moneda = remito.cotizacion[0].moneda[0]; 294 $scope.remito.moneda = remito.cotizacion[0].moneda[0];
295 $scope.remito.cotizacion = remito.cotizacion[0]; 295 $scope.remito.cotizacion = remito.cotizacion[0];
296 addArrayCabecera(cabeceras); 296 addArrayCabecera(cabeceras);
297 }, function() { 297 }, function() {
298 // funcion ejecutada cuando se cancela el modal 298 // funcion ejecutada cuando se cancela el modal
299 } 299 }
300 ); 300 );
301 }; 301 };
302 302
303 //validacion por domicilio y por plazo pago 303 //validacion por domicilio y por plazo pago
304 $scope.crearRemito = function() { 304 $scope.crearRemito = function() {
305 if(!$scope.remito.vendedor) { 305 if(!$scope.remito.vendedor) {
306 focaModalService.alert('Ingrese Vendedor'); 306 focaModalService.alert('Ingrese Vendedor');
307 return; 307 return;
308 } else if(!$scope.remito.cliente) { 308 } else if(!$scope.remito.cliente) {
309 focaModalService.alert('Ingrese Cliente'); 309 focaModalService.alert('Ingrese Cliente');
310 return; 310 return;
311 } else if(!$scope.remito.proveedor) { 311 } else if(!$scope.remito.proveedor) {
312 focaModalService.alert('Ingrese Proveedor'); 312 focaModalService.alert('Ingrese Proveedor');
313 return; 313 return;
314 } else if(!$scope.remito.moneda.id && !$scope.remito.moneda.ID) { 314 } else if(!$scope.remito.moneda.id && !$scope.remito.moneda.ID) {
315 focaModalService.alert('Ingrese Moneda'); 315 focaModalService.alert('Ingrese Moneda');
316 return; 316 return;
317 } else if(!$scope.remito.cotizacion.ID) { 317 } else if(!$scope.remito.cotizacion.ID) {
318 focaModalService.alert('Ingrese Cotización'); 318 focaModalService.alert('Ingrese Cotización');
319 return; 319 return;
320 } else if( 320 } else if(
321 $scope.remito.flete === undefined || $scope.remito.flete === null) 321 $scope.remito.flete === undefined || $scope.remito.flete === null)
322 { 322 {
323 focaModalService.alert('Ingrese Flete'); 323 focaModalService.alert('Ingrese Flete');
324 return; 324 return;
325 } else if($scope.articulosTabla.length === 0) { 325 } else if($scope.articulosTabla.length === 0) {
326 focaModalService.alert('Debe cargar al menos un articulo'); 326 focaModalService.alert('Debe cargar al menos un articulo');
327 return; 327 return;
328 } 328 }
329 var save = { 329 var save = {
330 remito: { 330 remito: {
331 id: $scope.remito.id, 331 id: $scope.remito.id,
332 fechaRemito: $scope.now.toISOString().slice(0, 19).replace('T', ' '), 332 fechaRemito: $scope.now.toISOString().slice(0, 19).replace('T', ' '),
333 idCliente: $scope.remito.cliente.COD, 333 idCliente: $scope.remito.cliente.COD,
334 nombreCliente: $scope.remito.cliente.NOM, 334 nombreCliente: $scope.remito.cliente.NOM,
335 cuitCliente: $scope.remito.cliente.CUIT, 335 cuitCliente: $scope.remito.cliente.CUIT,
336 responsabilidadIvaCliente: 0,//TODO, 336 responsabilidadIvaCliente: 0,//TODO,
337 descuento: 0,//TODO, 337 descuento: 0,//TODO,
338 importeNeto: 0,//TODO 338 importeNeto: 0,//TODO
339 importeExento: 0,//TODO 339 importeExento: 0,//TODO
340 importeIva: 0,//TODO 340 importeIva: 0,//TODO
341 importeIvaServicios: 0,//TODO 341 importeIvaServicios: 0,//TODO
342 importeImpuestoInterno: 0,//TODO 342 importeImpuestoInterno: 0,//TODO
343 importeImpuestoInterno1: 0,//TODO 343 importeImpuestoInterno1: 0,//TODO
344 importeImpuestoInterno2: 0,//TODO 344 importeImpuestoInterno2: 0,//TODO
345 percepcion: 0,//TODO 345 percepcion: 0,//TODO
346 percepcionIva: 0,//TODO 346 percepcionIva: 0,//TODO
347 redondeo: 0,//TODO 347 redondeo: 0,//TODO
348 total: $scope.getTotal(), 348 total: $scope.getTotal(),
349 numeroNotaPedido: $scope.remito.numeroNotaPedido, 349 numeroNotaPedido: $scope.remito.numeroNotaPedido,
350 anulado: false, 350 anulado: false,
351 planilla: 0,//TODO 351 planilla: 0,//TODO
352 lugar: 0,//TODO 352 lugar: 0,//TODO
353 cuentaMadre: 0,// 353 cuentaMadre: 0,//
354 cuentaContable: 0,//TODO 354 cuentaContable: 0,//TODO
355 asiento: 0,//TODO 355 asiento: 0,//TODO
356 e_hd: '',//TODO 356 e_hd: '',//TODO
357 c_hd: '', 357 c_hd: '',
358 numeroLiquidoProducto: 0,//TODO 358 numeroLiquidoProducto: 0,//TODO
359 idVendedor: $scope.remito.idVendedor, 359 idVendedor: $scope.remito.idVendedor,
360 idProveedor: $scope.remito.idProveedor, 360 idProveedor: $scope.remito.idProveedor,
361 idDomicilio: 0,//TODO 361 idDomicilio: 0,//TODO
362 idCotizacion: $scope.remito.cotizacion.ID, 362 idCotizacion: $scope.remito.cotizacion.ID,
363 idPrecioCondicion: $scope.remito.idPrecioCondicion, 363 idPrecioCondicion: $scope.remito.idPrecioCondicion,
364 flete: $scope.remito.flete, 364 flete: $scope.remito.flete,
365 fob: $scope.remito.fob, 365 fob: $scope.remito.fob,
366 bomba: $scope.remito.bomba, 366 bomba: $scope.remito.bomba,
367 kilometros: $scope.remito.kilometros, 367 kilometros: $scope.remito.kilometros,
368 domicilioStamp: $scope.remito.domicilioStamp, 368 domicilioStamp: $scope.remito.domicilioStamp,
369 estado: 0,//TODO 369 estado: 0,//TODO
370 destinoVenta: 0,//TODO 370 destinoVenta: 0,//TODO
371 operacionTipo: 0//TODO 371 operacionTipo: 0//TODO
372 }, 372 },
373 notaPedido: $scope.notaPedido 373 notaPedido: $scope.notaPedido
374 }; 374 };
375 crearRemitoService.crearRemito(save).then( 375 crearRemitoService.crearRemito(save).then(
376 function(data) { 376 function(data) {
377 remitoBusinessService.addArticulos($scope.articulosTabla, 377 remitoBusinessService.addArticulos($scope.articulosTabla,
378 data.data.id, $scope.remito.cotizacion.COTIZACION); 378 data.data.id, $scope.remito.cotizacion.COTIZACION);
379 379
380 focaModalService.alert('Remito creado'); 380 focaModalService.alert('Remito creado');
381 $scope.cabecera = []; 381 $scope.cabecera = [];
382 addCabecera('Moneda:', $scope.remito.moneda.DETALLE); 382 addCabecera('Moneda:', $scope.remito.moneda.DETALLE);
383 addCabecera( 383 addCabecera(
384 'Fecha cotizacion:', 384 'Fecha cotizacion:',
385 $filter('date')($scope.remito.cotizacion.FECHA, 'dd/MM/yyyy') 385 $filter('date')($scope.remito.cotizacion.FECHA, 'dd/MM/yyyy')
386 ); 386 );
387 addCabecera('Cotizacion:', $scope.remito.cotizacion.COTIZACION); 387 addCabecera('Cotizacion:', $scope.remito.cotizacion.COTIZACION);
388 $scope.remito.vendedor = {}; 388 $scope.remito.vendedor = {};
389 $scope.remito.cliente = {}; 389 $scope.remito.cliente = {};
390 $scope.remito.proveedor = {}; 390 $scope.remito.proveedor = {};
391 $scope.remito.domicilio = {}; 391 $scope.remito.domicilio = {};
392 $scope.remito.flete = null; 392 $scope.remito.flete = null;
393 $scope.remito.fob = null; 393 $scope.remito.fob = null;
394 $scope.remito.bomba = null; 394 $scope.remito.bomba = null;
395 $scope.remito.kilometros = null; 395 $scope.remito.kilometros = null;
396 $scope.articulosTabla = []; 396 $scope.articulosTabla = [];
397 crearRemitoService.getNumeroRemito().then( 397 crearRemitoService.getNumeroRemito().then(
398 function(res) { 398 function(res) {
399 $scope.puntoVenta = rellenar(res.data.sucursal, 4); 399 $scope.puntoVenta = rellenar(res.data.sucursal, 4);
400 $scope.comprobante = rellenar(res.data.numeroRemito, 8); 400 $scope.comprobante = rellenar(res.data.numeroRemito, 8);
401 }, 401 },
402 function(err) { 402 function(err) {
403 focaModalService 403 focaModalService
404 .alert('La terminal no esta configurada correctamente'); 404 .alert('La terminal no esta configurada correctamente');
405 console.info(err); 405 console.info(err);
406 } 406 }
407 ); 407 );
408 408
409 $scope.notaPedido = { 409 $scope.notaPedido = {
410 id: 0 410 id: 0
411 }; 411 };
412 } 412 }
413 ); 413 );
414 }; 414 };
415 415
416 $scope.seleccionarArticulo = function() { 416 $scope.seleccionarArticulo = function() {
417 if ($scope.idLista === undefined) { 417 if ($scope.idLista === undefined) {
418 focaModalService.alert( 418 focaModalService.alert(
419 'Primero seleccione una lista de precio y condicion'); 419 'Primero seleccione una lista de precio y condicion');
420 return; 420 return;
421 } 421 }
422 var modalInstance = $uibModal.open( 422 var modalInstance = $uibModal.open(
423 { 423 {
424 ariaLabelledBy: 'Busqueda de Productos', 424 ariaLabelledBy: 'Busqueda de Productos',
425 templateUrl: 'modal-busqueda-productos.html', 425 templateUrl: 'modal-busqueda-productos.html',
426 controller: 'modalBusquedaProductosCtrl', 426 controller: 'modalBusquedaProductosCtrl',
427 resolve: { 427 resolve: {
428 parametroProducto: { 428 parametroProducto: {
429 idLista: $scope.idLista, 429 idLista: $scope.idLista,
430 cotizacion: $scope.remito.cotizacion.COTIZACION, 430 cotizacion: $scope.remito.cotizacion.COTIZACION,
431 simbolo: $scope.remito.moneda.simbolo 431 simbolo: $scope.remito.moneda.simbolo
432 } 432 }
433 }, 433 },
434 size: 'lg' 434 size: 'lg'
435 } 435 }
436 ); 436 );
437 modalInstance.result.then( 437 modalInstance.result.then(
438 function(producto) { 438 function(producto) {
439 var newArt = 439 var newArt =
440 { 440 {
441 id: 0, 441 id: 0,
442 codigo: producto.codigo, 442 codigo: producto.codigo,
443 sector: producto.sector, 443 sector: producto.sector,
444 sectorCodigo: producto.sector + '-' + producto.codigo, 444 sectorCodigo: producto.sector + '-' + producto.codigo,
445 descripcion: producto.descripcion, 445 descripcion: producto.descripcion,
446 item: $scope.articulosTabla.length + 1, 446 item: $scope.articulosTabla.length + 1,
447 nombre: producto.descripcion, 447 nombre: producto.descripcion,
448 precio: parseFloat(producto.precio.toFixed(4)), 448 precio: parseFloat(producto.precio.toFixed(4)),
449 costoUnitario: producto.costo, 449 costoUnitario: producto.costo,
450 editCantidad: false, 450 editCantidad: false,
451 editPrecio: false, 451 editPrecio: false,
452 rubro: producto.CodRub, 452 rubro: producto.CodRub,
453 exentoUnitario: producto.precio, 453 exentoUnitario: producto.precio,
454 ivaUnitario: producto.IMPIVA, 454 ivaUnitario: producto.IMPIVA,
455 impuestoInternoUnitario: producto.ImpInt, 455 impuestoInternoUnitario: producto.ImpInt,
456 impuestoInterno1Unitario: producto.ImpInt2, 456 impuestoInterno1Unitario: producto.ImpInt2,
457 impuestoInterno2Unitario: producto.ImpInt3, 457 impuestoInterno2Unitario: producto.ImpInt3,
458 precioLista: producto.precio, 458 precioLista: producto.precio,
459 combustible: 1, 459 combustible: 1,
460 facturado: 0 460 facturado: 0
461 }; 461 };
462 $scope.articuloACargar = newArt; 462 $scope.articuloACargar = newArt;
463 $scope.cargando = false; 463 $scope.cargando = false;
464 }, function() { 464 }, function() {
465 // funcion ejecutada cuando se cancela el modal 465 // funcion ejecutada cuando se cancela el modal
466 } 466 }
467 ); 467 );
468 }; 468 };
469 469
470 $scope.seleccionarVendedor = function() { 470 $scope.seleccionarVendedor = function() {
471 var modalInstance = $uibModal.open( 471 var modalInstance = $uibModal.open(
472 { 472 {
473 ariaLabelledBy: 'Busqueda de Vendedores', 473 ariaLabelledBy: 'Busqueda de Vendedores',
474 templateUrl: 'modal-vendedores.html', 474 templateUrl: 'modal-vendedores.html',
475 controller: 'modalVendedoresCtrl', 475 controller: 'modalVendedoresCtrl',
476 size: 'lg' 476 size: 'lg'
477 } 477 }
478 ); 478 );
479 modalInstance.result.then( 479 modalInstance.result.then(
480 function(vendedor) { 480 function(vendedor) {
481 addCabecera('Vendedor:', vendedor.NomVen); 481 addCabecera('Vendedor:', vendedor.NomVen);
482 $scope.remito.idVendedor = vendedor.CodVen; 482 $scope.remito.idVendedor = vendedor.CodVen;
483 }, function() { 483 }, function() {
484 484
485 } 485 }
486 ); 486 );
487 }; 487 };
488 488
489 $scope.seleccionarProveedor = function() { 489 $scope.seleccionarProveedor = function() {
490 var modalInstance = $uibModal.open( 490 var modalInstance = $uibModal.open(
491 { 491 {
492 ariaLabelledBy: 'Busqueda de Proveedor', 492 ariaLabelledBy: 'Busqueda de Proveedor',
493 templateUrl: 'modal-proveedor.html', 493 templateUrl: 'modal-proveedor.html',
494 controller: 'focaModalProveedorCtrl', 494 controller: 'focaModalProveedorCtrl',
495 size: 'lg', 495 size: 'lg',
496 resolve: { 496 resolve: {
497 transportista: function() { 497 transportista: function() {
498 return false; 498 return false;
499 } 499 }
500 } 500 }
501 } 501 }
502 ); 502 );
503 modalInstance.result.then( 503 modalInstance.result.then(
504 function(proveedor) { 504 function(proveedor) {
505 $scope.remito.idProveedor = proveedor.COD; 505 $scope.remito.idProveedor = proveedor.COD;
506 addCabecera('Proveedor:', proveedor.NOM); 506 addCabecera('Proveedor:', proveedor.NOM);
507 }, function() { 507 }, function() {
508 508
509 } 509 }
510 ); 510 );
511 }; 511 };
512 512
513 $scope.seleccionarCliente = function() { 513 $scope.seleccionarCliente = function() {
514 514
515 var modalInstance = $uibModal.open( 515 var modalInstance = $uibModal.open(
516 { 516 {
517 ariaLabelledBy: 'Busqueda de Cliente', 517 ariaLabelledBy: 'Busqueda de Cliente',
518 templateUrl: 'foca-busqueda-cliente-modal.html', 518 templateUrl: 'foca-busqueda-cliente-modal.html',
519 controller: 'focaBusquedaClienteModalController', 519 controller: 'focaBusquedaClienteModalController',
520 size: 'lg' 520 size: 'lg'
521 } 521 }
522 ); 522 );
523 modalInstance.result.then( 523 modalInstance.result.then(
524 function(cliente) { 524 function(cliente) {
525 $scope.abrirModalDomicilios(cliente); 525 $scope.abrirModalDomicilios(cliente);
526 }, function() { 526 }, function() {
527 527
528 } 528 }
529 ); 529 );
530 }; 530 };
531 531
532 $scope.abrirModalDomicilios = function(cliente) { 532 $scope.abrirModalDomicilios = function(cliente) {
533 var modalInstanceDomicilio = $uibModal.open( 533 var modalInstanceDomicilio = $uibModal.open(
534 { 534 {
535 ariaLabelledBy: 'Busqueda de Domicilios', 535 ariaLabelledBy: 'Busqueda de Domicilios',
536 templateUrl: 'modal-domicilio.html', 536 templateUrl: 'modal-domicilio.html',
537 controller: 'focaModalDomicilioController', 537 controller: 'focaModalDomicilioController',
538 size: 'lg', 538 size: 'lg',
539 resolve: { idCliente: function() { return cliente.cod; }} 539 resolve: { idCliente: function() { return cliente.cod; }}
540 } 540 }
541 ); 541 );
542 modalInstanceDomicilio.result.then( 542 modalInstanceDomicilio.result.then(
543 function(domicilio) { 543 function(domicilio) {
544 //$scope.remito.domicilio.id = domicilio.nivel2; 544 //$scope.remito.domicilio.id = domicilio.nivel2;
545 $scope.remito.cliente = { 545 $scope.remito.cliente = {
546 COD: cliente.cod, 546 COD: cliente.cod,
547 CUIT: cliente.cuit, 547 CUIT: cliente.cuit,
548 NOM: cliente.nom 548 NOM: cliente.nom
549 }; 549 };
550 550
551 addCabecera('Cliente:', cliente.nom); 551 addCabecera('Cliente:', cliente.nom);
552 var domicilioStamp = 552 var domicilioStamp =
553 domicilio.Calle + ' ' + domicilio.Numero + ', ' + 553 domicilio.Calle + ' ' + domicilio.Numero + ', ' +
554 domicilio.Localidad + ', ' + domicilio.Provincia; 554 domicilio.Localidad + ', ' + domicilio.Provincia;
555 $scope.remito.domicilioStamp = domicilioStamp; 555 $scope.remito.domicilioStamp = domicilioStamp;
556 addCabecera('Domicilio:', domicilioStamp); 556 addCabecera('Domicilio:', domicilioStamp);
557 }, function() { 557 }, function() {
558 $scope.seleccionarCliente(); 558 $scope.seleccionarCliente();
559 return; 559 return;
560 } 560 }
561 ); 561 );
562 }; 562 };
563 563
564 $scope.mostrarFichaCliente = function() { 564 $scope.mostrarFichaCliente = function() {
565 $uibModal.open( 565 $uibModal.open(
566 { 566 {
567 ariaLabelledBy: 'Datos del Cliente', 567 ariaLabelledBy: 'Datos del Cliente',
568 templateUrl: 'foca-crear-remito-ficha-cliente.html', 568 templateUrl: 'foca-crear-remito-ficha-cliente.html',
569 controller: 'focaCrearRemitoFichaClienteController', 569 controller: 'focaCrearRemitoFichaClienteController',
570 size: 'lg' 570 size: 'lg'
571 } 571 }
572 ); 572 );
573 }; 573 };
574 574
575 $scope.getTotal = function() { 575 $scope.getTotal = function() {
576 var total = 0; 576 var total = 0;
577 var arrayTempArticulos = $scope.articulosTabla; 577 var arrayTempArticulos = $scope.articulosTabla;
578 for (var i = 0; i < arrayTempArticulos.length; i++) { 578 for (var i = 0; i < arrayTempArticulos.length; i++) {
579 total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; 579 total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad;
580 } 580 }
581 return parseFloat(total.toFixed(2)); 581 return parseFloat(total.toFixed(2));
582 }; 582 };
583 583
584 $scope.getSubTotal = function() { 584 $scope.getSubTotal = function() {
585 if($scope.articuloACargar) { 585 if($scope.articuloACargar) {
586 return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; 586 return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad;
587 } 587 }
588 }; 588 };
589 589
590 $scope.abrirModalListaPrecio = function() { 590 $scope.abrirModalListaPrecio = function() {
591 var modalInstance = $uibModal.open( 591 var modalInstance = $uibModal.open(
592 { 592 {
593 ariaLabelledBy: 'Busqueda de Precio Condición', 593 ariaLabelledBy: 'Busqueda de Precio Condición',
594 templateUrl: 'modal-precio-condicion.html', 594 templateUrl: 'modal-precio-condicion.html',
595 controller: 'focaModalPrecioCondicionController', 595 controller: 'focaModalPrecioCondicionController',
596 size: 'lg' 596 size: 'lg'
597 } 597 }
598 ); 598 );
599 modalInstance.result.then( 599 modalInstance.result.then(
600 function(precioCondicion) { 600 function(precioCondicion) {
601 var cabecera = ''; 601 var cabecera = '';
602 var plazosConcat = ''; 602 var plazosConcat = '';
603 if(!Array.isArray(precioCondicion)) { 603 if(!Array.isArray(precioCondicion)) {
604 $scope.remito.idPrecioCondicion = precioCondicion.id; 604 $scope.remito.idPrecioCondicion = precioCondicion.id;
605 $scope.plazosPagos = precioCondicion.plazoPago; 605 $scope.plazosPagos = precioCondicion.plazoPago;
606 $scope.idLista = precioCondicion.idListaPrecio; 606 $scope.idLista = precioCondicion.idListaPrecio;
607 for(var i = 0; i < precioCondicion.plazoPago.length; i++) { 607 for(var i = 0; i < precioCondicion.plazoPago.length; i++) {
608 plazosConcat += precioCondicion.plazoPago[i].dias + ' '; 608 plazosConcat += precioCondicion.plazoPago[i].dias + ' ';
609 } 609 }
610 cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); 610 cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim();
611 } else { //Cuando se ingresan los plazos manualmente 611 } else { //Cuando se ingresan los plazos manualmente
612 $scope.remito.idPrecioCondicion = 0; 612 $scope.remito.idPrecioCondicion = 0;
613 $scope.idLista = -1; //-1, el modal productos busca todos los productos 613 $scope.idLista = -1; //-1, el modal productos busca todos los productos
614 $scope.plazosPagos = precioCondicion; 614 $scope.plazosPagos = precioCondicion;
615 for(var j = 0; j < precioCondicion.length; j++) { 615 for(var j = 0; j < precioCondicion.length; j++) {
616 plazosConcat += precioCondicion[j].dias + ' '; 616 plazosConcat += precioCondicion[j].dias + ' ';
617 } 617 }
618 cabecera = 'Ingreso manual ' + plazosConcat.trim(); 618 cabecera = 'Ingreso manual ' + plazosConcat.trim();
619 } 619 }
620 $scope.articulosTabla = []; 620 $scope.articulosTabla = [];
621 addCabecera('Precios y condiciones:', cabecera); 621 addCabecera('Precios y condiciones:', cabecera);
622 }, function() { 622 }, function() {
623 623
624 } 624 }
625 ); 625 );
626 }; 626 };
627 627
628 $scope.abrirModalFlete = function() { 628 $scope.abrirModalFlete = function() {
629 var modalInstance = $uibModal.open( 629 var modalInstance = $uibModal.open(
630 { 630 {
631 ariaLabelledBy: 'Busqueda de Flete', 631 ariaLabelledBy: 'Busqueda de Flete',
632 templateUrl: 'modal-flete.html', 632 templateUrl: 'modal-flete.html',
633 controller: 'focaModalFleteController', 633 controller: 'focaModalFleteController',
634 size: 'lg', 634 size: 'lg',
635 resolve: { 635 resolve: {
636 parametrosFlete: 636 parametrosFlete:
637 function() { 637 function() {
638 return { 638 return {
639 flete: $scope.remito.flete ? '1' : 639 flete: $scope.remito.flete ? '1' :
640 ($scope.remito.fob ? 'FOB' : 640 ($scope.remito.fob ? 'FOB' :
641 ($scope.remito.flete === undefined ? null : '0')), 641 ($scope.remito.flete === undefined ? null : '0')),
642 bomba: $scope.remito.bomba ? '1' : 642 bomba: $scope.remito.bomba ? '1' :
643 ($scope.remito.bomba === undefined ? null : '0'), 643 ($scope.remito.bomba === undefined ? null : '0'),
644 kilometros: $scope.remito.kilometros 644 kilometros: $scope.remito.kilometros
645 }; 645 };
646 } 646 }
647 } 647 }
648 } 648 }
649 ); 649 );
650 modalInstance.result.then( 650 modalInstance.result.then(
651 function(datos) { 651 function(datos) {
652 $scope.remito.flete = datos.flete; 652 $scope.remito.flete = datos.flete;
653 $scope.remito.fob = datos.FOB; 653 $scope.remito.fob = datos.FOB;
654 $scope.remito.bomba = datos.bomba; 654 $scope.remito.bomba = datos.bomba;
655 $scope.remito.kilometros = datos.kilometros; 655 $scope.remito.kilometros = datos.kilometros;
656 656
657 addCabecera('Flete:', datos.flete ? 'Si' : 657 addCabecera('Flete:', datos.flete ? 'Si' :
658 ($scope.remito.fob ? 'FOB' : 'No')); 658 ($scope.remito.fob ? 'FOB' : 'No'));
659 if(datos.flete) { 659 if(datos.flete) {
660 addCabecera('Bomba:', datos.bomba ? 'Si' : 'No'); 660 addCabecera('Bomba:', datos.bomba ? 'Si' : 'No');
661 addCabecera('Kilometros:', datos.kilometros); 661 addCabecera('Kilometros:', datos.kilometros);
662 } else { 662 } else {
663 removeCabecera('Bomba:'); 663 removeCabecera('Bomba:');
664 removeCabecera('Kilometros:'); 664 removeCabecera('Kilometros:');
665 $scope.remito.fob = false; 665 $scope.remito.fob = false;
666 $scope.remito.bomba = false; 666 $scope.remito.bomba = false;
667 $scope.remito.kilometros = null; 667 $scope.remito.kilometros = null;
668 } 668 }
669 }, function() { 669 }, function() {
670 670
671 } 671 }
672 ); 672 );
673 }; 673 };
674 674
675 $scope.abrirModalMoneda = function() { 675 $scope.abrirModalMoneda = function() {
676 var modalInstance = $uibModal.open( 676 var modalInstance = $uibModal.open(
677 { 677 {
678 ariaLabelledBy: 'Busqueda de Moneda', 678 ariaLabelledBy: 'Busqueda de Moneda',
679 templateUrl: 'modal-moneda.html', 679 templateUrl: 'modal-moneda.html',
680 controller: 'focaModalMonedaController', 680 controller: 'focaModalMonedaController',
681 size: 'lg' 681 size: 'lg'
682 } 682 }
683 ); 683 );
684 modalInstance.result.then( 684 modalInstance.result.then(
685 function(moneda) { 685 function(moneda) {
686 $scope.abrirModalCotizacion(moneda); 686 $scope.abrirModalCotizacion(moneda);
687 }, function() { 687 }, function() {
688 688
689 } 689 }
690 ); 690 );
691 }; 691 };
692 692
693 $scope.abrirModalCotizacion = function(moneda) { 693 $scope.abrirModalCotizacion = function(moneda) {
694 var modalInstance = $uibModal.open( 694 var modalInstance = $uibModal.open(
695 { 695 {
696 ariaLabelledBy: 'Busqueda de Cotización', 696 ariaLabelledBy: 'Busqueda de Cotización',
697 templateUrl: 'modal-cotizacion.html', 697 templateUrl: 'modal-cotizacion.html',
698 controller: 'focaModalCotizacionController', 698 controller: 'focaModalCotizacionController',
699 size: 'lg', 699 size: 'lg',
700 resolve: {idMoneda: function() {return moneda.ID;}} 700 resolve: {idMoneda: function() {return moneda.ID;}}
701 } 701 }
702 ); 702 );
703 modalInstance.result.then( 703 modalInstance.result.then(
704 function(cotizacion) { 704 function(cotizacion) {
705 var articulosTablaTemp = $scope.articulosTabla; 705 var articulosTablaTemp = $scope.articulosTabla;
706 for(var i = 0; i < articulosTablaTemp.length; i++) { 706 for(var i = 0; i < articulosTablaTemp.length; i++) {
707 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * 707 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio *
708 $scope.remito.cotizacion.COTIZACION; 708 $scope.remito.cotizacion.COTIZACION;
709 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / 709 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio /
710 cotizacion.COTIZACION; 710 cotizacion.COTIZACION;
711 } 711 }
712 $scope.articulosTabla = articulosTablaTemp; 712 $scope.articulosTabla = articulosTablaTemp;
713 $scope.remito.moneda = moneda; 713 $scope.remito.moneda = moneda;
714 $scope.remito.cotizacion = cotizacion; 714 $scope.remito.cotizacion = cotizacion;
715 addCabecera('Moneda:', moneda.DETALLE); 715 addCabecera('Moneda:', moneda.DETALLE);
716 addCabecera( 716 addCabecera(
717 'Fecha cotizacion:', 717 'Fecha cotizacion:',
718 $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') 718 $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy')
719 ); 719 );
720 addCabecera('Cotizacion:', cotizacion.COTIZACION); 720 addCabecera('Cotizacion:', cotizacion.COTIZACION);
721 }, function() { 721 }, function() {
722 722
723 } 723 }
724 ); 724 );
725 }; 725 };
726 726
727 $scope.agregarATabla = function(key) { 727 $scope.agregarATabla = function(key) {
728 if(key === 13) { 728 if(key === 13) {
729 if($scope.articuloACargar.cantidad === undefined || 729 if($scope.articuloACargar.cantidad === undefined ||
730 $scope.articuloACargar.cantidad === 0 || 730 $scope.articuloACargar.cantidad === 0 ||
731 $scope.articuloACargar.cantidad === null ) { 731 $scope.articuloACargar.cantidad === null ) {
732 focaModalService.alert('El valor debe ser al menos 1'); 732 focaModalService.alert('El valor debe ser al menos 1');
733 return; 733 return;
734 } 734 }
735 delete $scope.articuloACargar.sectorCodigo; 735 delete $scope.articuloACargar.sectorCodigo;
736 $scope.articulosTabla.push($scope.articuloACargar); 736 $scope.articulosTabla.push($scope.articuloACargar);
737 $scope.cargando = true; 737 $scope.cargando = true;
738 } 738 }
739 }; 739 };
740 740
741 $scope.quitarArticulo = function(key) { 741 $scope.quitarArticulo = function(key) {
742 $scope.articulosTabla.splice(key, 1); 742 $scope.articulosTabla.splice(key, 1);
743 }; 743 };
744 744
745 $scope.editarArticulo = function(key, articulo) { 745 $scope.editarArticulo = function(key, articulo) {
746 if(key === 13) { 746 if(key === 13) {
747 if(articulo.cantidad === null || articulo.cantidad === 0 || 747 if(articulo.cantidad === null || articulo.cantidad === 0 ||
748 articulo.cantidad === undefined) { 748 articulo.cantidad === undefined) {
749 focaModalService.alert('El valor debe ser al menos 1'); 749 focaModalService.alert('El valor debe ser al menos 1');
750 return; 750 return;
751 } 751 }
752 articulo.editCantidad = false; 752 articulo.editCantidad = false;
753 articulo.editPrecio = false; 753 articulo.editPrecio = false;
754 } 754 }
755 }; 755 };
756 756
757 $scope.cambioEdit = function(articulo, propiedad) { 757 $scope.cambioEdit = function(articulo, propiedad) {
758 if(propiedad === 'cantidad') { 758 if(propiedad === 'cantidad') {
759 articulo.editCantidad = true; 759 articulo.editCantidad = true;
760 } else if(propiedad === 'precio') { 760 } else if(propiedad === 'precio') {
761 articulo.editPrecio = true; 761 articulo.editPrecio = true;
762 } 762 }
763 }; 763 };
764 764
765 $scope.limpiarFlete = function() { 765 $scope.limpiarFlete = function() {
766 $scope.remito.fleteNombre = ''; 766 $scope.remito.fleteNombre = '';
767 $scope.remito.chofer = ''; 767 $scope.remito.chofer = '';
768 $scope.remito.vehiculo = ''; 768 $scope.remito.vehiculo = '';
769 $scope.remito.kilometros = ''; 769 $scope.remito.kilometros = '';
770 $scope.remito.costoUnitarioKmFlete = ''; 770 $scope.remito.costoUnitarioKmFlete = '';
771 $scope.choferes = ''; 771 $scope.choferes = '';
772 $scope.vehiculos = ''; 772 $scope.vehiculos = '';
773 }; 773 };
774 774
775 $scope.limpiarPantalla = function() { 775 $scope.limpiarPantalla = function() {
776 $scope.limpiarFlete(); 776 $scope.limpiarFlete();
777 $scope.remito.flete = '0'; 777 $scope.remito.flete = '0';
778 $scope.remito.bomba = '0'; 778 $scope.remito.bomba = '0';
779 $scope.remito.precioCondicion = ''; 779 $scope.remito.precioCondicion = '';
780 $scope.articulosTabla = []; 780 $scope.articulosTabla = [];
781 $scope.remito.vendedor.nombre = ''; 781 $scope.remito.vendedor.nombre = '';
782 $scope.remito.cliente = {nombre: ''}; 782 $scope.remito.cliente = {nombre: ''};
783 $scope.remito.domicilio = {dom: ''}; 783 $scope.remito.domicilio = {dom: ''};
784 $scope.domiciliosCliente = []; 784 $scope.domiciliosCliente = [];
785 }; 785 };
786 786
787 $scope.resetFilter = function() { 787 $scope.resetFilter = function() {
788 $scope.articuloACargar = {}; 788 $scope.articuloACargar = {};
789 $scope.cargando = true; 789 $scope.cargando = true;
790 }; 790 };
791 791
792 $scope.selectFocus = function($event) { 792 $scope.selectFocus = function($event) {
793 $event.target.select(); 793 $event.target.select();
794 }; 794 };
795 795
796 $scope.salir = function() { 796 $scope.salir = function() {
797 $location.path('/'); 797 $location.path('/');
798 }; 798 };
799 function addArrayCabecera(array) { 799 function addArrayCabecera(array) {
800 for(var i = 0; i < array.length; i++) { 800 for(var i = 0; i < array.length; i++) {
801 addCabecera(array[i].label, array[i].valor); 801 addCabecera(array[i].label, array[i].valor);
802 } 802 }
803 } 803 }
804 804
805 function addCabecera(label, valor) { 805 function addCabecera(label, valor) {
806 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); 806 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true);
807 if(propiedad.length === 1) { 807 if(propiedad.length === 1) {
808 propiedad[0].valor = valor; 808 propiedad[0].valor = valor;
809 } else { 809 } else {
810 $scope.cabecera.push({label: label, valor: valor}); 810 $scope.cabecera.push({label: label, valor: valor});
811 } 811 }
812 } 812 }
813 813
814 function removeCabecera(label) { 814 function removeCabecera(label) {
815 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); 815 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true);
816 if(propiedad.length === 1) { 816 if(propiedad.length === 1) {
817 $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); 817 $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1);
818 } 818 }
819 } 819 }
820 820
821 function rellenar(relleno, longitud) { 821 function rellenar(relleno, longitud) {
822 relleno = '' + relleno; 822 relleno = '' + relleno;
823 while (relleno.length < longitud) { 823 while (relleno.length < longitud) {
824 relleno = '0' + relleno; 824 relleno = '0' + relleno;
825 } 825 }
826 826
827 return relleno; 827 return relleno;
828 } 828 }
829 829
830 function varlidarRemitoFacturado(funcion) { 830 function varlidarRemitoFacturado(funcion) {
831 if($scope.remito.estado === 5) { 831 if($scope.remito.estado === 5) {
832 focaModalService.alert('No se puede editar un remito facturado'); 832 focaModalService.alert('No se puede editar un remito facturado');
833 } 833 }
834 else { 834 else {
835 funcion(); 835 funcion();
836 } 836 }
837 } 837 }
838 } 838 }
839 ]); 839 ]);
840 840