Commit 85c3717e22c36d0639609b93e0f8be0dae6b80b9

Authored by Pablo Marco del Pont
1 parent f1b869c60b
Exists in master

Añadí método de guardado de nota de pedido en seguimiento.

Showing 1 changed file with 10 additions and 0 deletions   Show diff stats
src/js/controller.js
1 angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', 1 angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
2 [ 2 [
3 '$scope', '$uibModal', '$location', '$filter', 'crearNotaPedidoService', 3 '$scope', '$uibModal', '$location', '$filter', 'crearNotaPedidoService',
4 'focaModalService', 'notaPedidoBusinessService', '$rootScope', 4 'focaModalService', 'notaPedidoBusinessService', '$rootScope',
5 function( 5 function(
6 $scope, $uibModal, $location, $filter, crearNotaPedidoService, focaModalService, 6 $scope, $uibModal, $location, $filter, crearNotaPedidoService, focaModalService,
7 notaPedidoBusinessService, $rootScope 7 notaPedidoBusinessService, $rootScope
8 ) { 8 ) {
9 $scope.botonera = [ 9 $scope.botonera = [
10 {texto: 'Vendedor', accion: function() {$scope.seleccionarVendedor();}}, 10 {texto: 'Vendedor', accion: function() {$scope.seleccionarVendedor();}},
11 {texto: 'Cliente', accion: function() {$scope.seleccionarCliente();}}, 11 {texto: 'Cliente', accion: function() {$scope.seleccionarCliente();}},
12 {texto: 'Proveedor', accion: function() {$scope.seleccionarProveedor();}}, 12 {texto: 'Proveedor', accion: function() {$scope.seleccionarProveedor();}},
13 {texto: 'Moneda', accion: function() {$scope.abrirModalMoneda();}}, 13 {texto: 'Moneda', accion: function() {$scope.abrirModalMoneda();}},
14 { 14 {
15 texto: 'Precios y condiciones', 15 texto: 'Precios y condiciones',
16 accion: function() {$scope.abrirModalListaPrecio();}}, 16 accion: function() {$scope.abrirModalListaPrecio();}},
17 {texto: 'Flete', accion: function() {$scope.abrirModalFlete();}}, 17 {texto: 'Flete', accion: function() {$scope.abrirModalFlete();}},
18 {texto: '', accion: function() {}}, 18 {texto: '', accion: function() {}},
19 {texto: '', accion: function() {}} 19 {texto: '', accion: function() {}}
20 ]; 20 ];
21 $scope.datepickerAbierto = false; 21 $scope.datepickerAbierto = false;
22 22
23 $scope.show = false; 23 $scope.show = false;
24 $scope.cargando = true; 24 $scope.cargando = true;
25 $scope.dateOptions = { 25 $scope.dateOptions = {
26 maxDate: new Date(), 26 maxDate: new Date(),
27 minDate: new Date(2010, 0, 1) 27 minDate: new Date(2010, 0, 1)
28 }; 28 };
29 29
30 $scope.notaPedido = { 30 $scope.notaPedido = {
31 vendedor: {}, 31 vendedor: {},
32 cliente: {}, 32 cliente: {},
33 proveedor: {}, 33 proveedor: {},
34 domicilio: {dom: ''}, 34 domicilio: {dom: ''},
35 moneda: {}, 35 moneda: {},
36 cotizacion: {} 36 cotizacion: {}
37 }; 37 };
38 var monedaPorDefecto; 38 var monedaPorDefecto;
39 //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' 39 //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]'
40 crearNotaPedidoService.getCotizacionByIdMoneda(1).then(function(res) { 40 crearNotaPedidoService.getCotizacionByIdMoneda(1).then(function(res) {
41 monedaPorDefecto = { 41 monedaPorDefecto = {
42 id: res.data[0].ID, 42 id: res.data[0].ID,
43 detalle: res.data[0].DETALLE, 43 detalle: res.data[0].DETALLE,
44 simbolo: res.data[0].SIMBOLO, 44 simbolo: res.data[0].SIMBOLO,
45 cotizaciones: res.data[0].cotizaciones 45 cotizaciones: res.data[0].cotizaciones
46 }; 46 };
47 addCabecera('Moneda:', monedaPorDefecto.detalle); 47 addCabecera('Moneda:', monedaPorDefecto.detalle);
48 addCabecera('Fecha cotizacion:', 48 addCabecera('Fecha cotizacion:',
49 new Date(monedaPorDefecto.cotizaciones[0].FECHA).toLocaleDateString()); 49 new Date(monedaPorDefecto.cotizaciones[0].FECHA).toLocaleDateString());
50 addCabecera('Cotizacion:', monedaPorDefecto.cotizaciones[0].VENDEDOR); 50 addCabecera('Cotizacion:', monedaPorDefecto.cotizaciones[0].VENDEDOR);
51 $scope.notaPedido.moneda = monedaPorDefecto; 51 $scope.notaPedido.moneda = monedaPorDefecto;
52 $scope.notaPedido.cotizacion = monedaPorDefecto.cotizaciones[0]; 52 $scope.notaPedido.cotizacion = monedaPorDefecto.cotizaciones[0];
53 }); 53 });
54 54
55 $scope.cabecera = []; 55 $scope.cabecera = [];
56 $scope.showCabecera = true; 56 $scope.showCabecera = true;
57 57
58 $scope.now = new Date(); 58 $scope.now = new Date();
59 $scope.puntoVenta = '0000'; 59 $scope.puntoVenta = '0000';
60 $scope.comprobante = '00000000'; 60 $scope.comprobante = '00000000';
61 $scope.articulosTabla = []; 61 $scope.articulosTabla = [];
62 $scope.idLista = undefined; 62 $scope.idLista = undefined;
63 //La pantalla solo se usa para cargar pedidos 63 //La pantalla solo se usa para cargar pedidos
64 //var notaPedidoTemp = crearNotaPedidoService.getNotaPedido(); 64 //var notaPedidoTemp = crearNotaPedidoService.getNotaPedido();
65 65
66 crearNotaPedidoService.getPrecioCondicion().then( 66 crearNotaPedidoService.getPrecioCondicion().then(
67 function(res) { 67 function(res) {
68 $scope.precioCondiciones = res.data; 68 $scope.precioCondiciones = res.data;
69 } 69 }
70 ); 70 );
71 71
72 crearNotaPedidoService.getNumeroNotaPedido().then( 72 crearNotaPedidoService.getNumeroNotaPedido().then(
73 function(res) { 73 function(res) {
74 $scope.puntoVenta = rellenar(res.data.sucursal, 4); 74 $scope.puntoVenta = rellenar(res.data.sucursal, 4);
75 $scope.comprobante = rellenar(res.data.numeroNotaPedido, 8); 75 $scope.comprobante = rellenar(res.data.numeroNotaPedido, 8);
76 }, 76 },
77 function(err) { 77 function(err) {
78 focaModalService.alert('La terminal no esta configurada correctamente'); 78 focaModalService.alert('La terminal no esta configurada correctamente');
79 console.info(err); 79 console.info(err);
80 } 80 }
81 ); 81 );
82 //La pantalla solo se usa para cargar pedidos 82 //La pantalla solo se usa para cargar pedidos
83 // if (notaPedidoTemp !== undefined) { 83 // if (notaPedidoTemp !== undefined) {
84 // notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga); 84 // notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga);
85 // $scope.notaPedido = notaPedidoTemp; 85 // $scope.notaPedido = notaPedidoTemp;
86 // $scope.notaPedido.flete = ($scope.notaPedido.flete).toString(); 86 // $scope.notaPedido.flete = ($scope.notaPedido.flete).toString();
87 // $scope.notaPedido.bomba = ($scope.notaPedido.bomba).toString(); 87 // $scope.notaPedido.bomba = ($scope.notaPedido.bomba).toString();
88 // $scope.idLista = $scope.notaPedido.precioCondicion; 88 // $scope.idLista = $scope.notaPedido.precioCondicion;
89 // crearNotaPedidoService 89 // crearNotaPedidoService
90 // .getArticulosByIdNotaPedido($scope.notaPedido.id).then( 90 // .getArticulosByIdNotaPedido($scope.notaPedido.id).then(
91 // function(res) { 91 // function(res) {
92 // $scope.articulosTabla = res.data; 92 // $scope.articulosTabla = res.data;
93 // } 93 // }
94 // ); 94 // );
95 //TODO DOMICILIOS QUE SE CARGAN AL EDITAR NOTA DE PEDIDO 95 //TODO DOMICILIOS QUE SE CARGAN AL EDITAR NOTA DE PEDIDO
96 //(NO REQUERIDO EN ESTA VERSION) 96 //(NO REQUERIDO EN ESTA VERSION)
97 // crearNotaPedidoService.getDomiciliosByIdNotaPedido($scope.notaPedido.id).then( 97 // crearNotaPedidoService.getDomiciliosByIdNotaPedido($scope.notaPedido.id).then(
98 // function(res) { 98 // function(res) {
99 // $scope.notaPedido.domicilio = res.data; 99 // $scope.notaPedido.domicilio = res.data;
100 // } 100 // }
101 // ); 101 // );
102 // } else { 102 // } else {
103 // $scope.notaPedido.fechaCarga = new Date(); 103 // $scope.notaPedido.fechaCarga = new Date();
104 // $scope.notaPedido.bomba = '0'; 104 // $scope.notaPedido.bomba = '0';
105 // $scope.notaPedido.flete = '0'; 105 // $scope.notaPedido.flete = '0';
106 // $scope.idLista = undefined; 106 // $scope.idLista = undefined;
107 // } 107 // }
108 //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO 108 //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO
109 // $scope.addNewDom = function() { 109 // $scope.addNewDom = function() {
110 // $scope.notaPedido.domicilio.push({ 'id': 0 }); 110 // $scope.notaPedido.domicilio.push({ 'id': 0 });
111 // }; 111 // };
112 // $scope.removeNewChoice = function(choice) { 112 // $scope.removeNewChoice = function(choice) {
113 // if ($scope.notaPedido.domicilio.length > 1) { 113 // if ($scope.notaPedido.domicilio.length > 1) {
114 // $scope.notaPedido.domicilio.splice($scope.notaPedido.domicilio.findIndex( 114 // $scope.notaPedido.domicilio.splice($scope.notaPedido.domicilio.findIndex(
115 // function(c) { 115 // function(c) {
116 // return c.$$hashKey === choice.$$hashKey; 116 // return c.$$hashKey === choice.$$hashKey;
117 // } 117 // }
118 // ), 1); 118 // ), 1);
119 // } 119 // }
120 // }; 120 // };
121 121
122 $scope.crearNotaPedido = function() { 122 $scope.crearNotaPedido = function() {
123 if(!$scope.notaPedido.vendedor.codigo) { 123 if(!$scope.notaPedido.vendedor.codigo) {
124 focaModalService.alert('Ingrese Vendedor'); 124 focaModalService.alert('Ingrese Vendedor');
125 return; 125 return;
126 } else if(!$scope.notaPedido.cliente.cod) { 126 } else if(!$scope.notaPedido.cliente.cod) {
127 focaModalService.alert('Ingrese Cliente'); 127 focaModalService.alert('Ingrese Cliente');
128 return; 128 return;
129 } else if(!$scope.notaPedido.proveedor.codigo) { 129 } else if(!$scope.notaPedido.proveedor.codigo) {
130 focaModalService.alert('Ingrese Proveedor'); 130 focaModalService.alert('Ingrese Proveedor');
131 return; 131 return;
132 } else if(!$scope.notaPedido.moneda.id) { 132 } else if(!$scope.notaPedido.moneda.id) {
133 focaModalService.alert('Ingrese Moneda'); 133 focaModalService.alert('Ingrese Moneda');
134 return; 134 return;
135 } else if(!$scope.notaPedido.cotizacion.ID) { 135 } else if(!$scope.notaPedido.cotizacion.ID) {
136 focaModalService.alert('Ingrese Cotización'); 136 focaModalService.alert('Ingrese Cotización');
137 return; 137 return;
138 } else if(!$scope.plazosPagos) { 138 } else if(!$scope.plazosPagos) {
139 focaModalService.alert('Ingrese Precios y Condiciones'); 139 focaModalService.alert('Ingrese Precios y Condiciones');
140 return; 140 return;
141 } else if( 141 } else if(
142 $scope.notaPedido.flete === undefined || $scope.notaPedido.flete === null) 142 $scope.notaPedido.flete === undefined || $scope.notaPedido.flete === null)
143 { 143 {
144 focaModalService.alert('Ingrese Flete'); 144 focaModalService.alert('Ingrese Flete');
145 return; 145 return;
146 } else if(!$scope.notaPedido.domicilio.id) { 146 } else if(!$scope.notaPedido.domicilio.id) {
147 focaModalService.alert('Ingrese Domicilio'); 147 focaModalService.alert('Ingrese Domicilio');
148 return; 148 return;
149 } else if($scope.articulosTabla.length === 0) { 149 } else if($scope.articulosTabla.length === 0) {
150 focaModalService.alert('Debe cargar al menos un articulo'); 150 focaModalService.alert('Debe cargar al menos un articulo');
151 return; 151 return;
152 } 152 }
153 var date = new Date(); 153 var date = new Date();
154 var notaPedido = { 154 var notaPedido = {
155 id: 0, 155 id: 0,
156 fechaCarga: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) 156 fechaCarga: new Date(date.getTime() - (date.getTimezoneOffset() * 60000))
157 .toISOString().slice(0, 19).replace('T', ' '), 157 .toISOString().slice(0, 19).replace('T', ' '),
158 idVendedor: $scope.notaPedido.vendedor.codigo, 158 idVendedor: $scope.notaPedido.vendedor.codigo,
159 idCliente: $scope.notaPedido.cliente.cod, 159 idCliente: $scope.notaPedido.cliente.cod,
160 nombreCliente: $scope.notaPedido.cliente.nom, 160 nombreCliente: $scope.notaPedido.cliente.nom,
161 cuitCliente: $scope.notaPedido.cliente.cuit, 161 cuitCliente: $scope.notaPedido.cliente.cuit,
162 idProveedor: $scope.notaPedido.proveedor.codigo, 162 idProveedor: $scope.notaPedido.proveedor.codigo,
163 idDomicilio: $scope.notaPedido.domicilio.id, 163 idDomicilio: $scope.notaPedido.domicilio.id,
164 idCotizacion: $scope.notaPedido.cotizacion.ID, 164 idCotizacion: $scope.notaPedido.cotizacion.ID,
165 idPrecioCondicion: $scope.notaPedido.idPrecioCondicion, 165 idPrecioCondicion: $scope.notaPedido.idPrecioCondicion,
166 cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, 166 cotizacion: $scope.notaPedido.cotizacion.VENDEDOR,
167 flete: $scope.notaPedido.flete, 167 flete: $scope.notaPedido.flete,
168 fob: $scope.notaPedido.fob, 168 fob: $scope.notaPedido.fob,
169 bomba: $scope.notaPedido.bomba, 169 bomba: $scope.notaPedido.bomba,
170 kilometros: $scope.notaPedido.kilometros, 170 kilometros: $scope.notaPedido.kilometros,
171 domicilioStamp: $scope.notaPedido.domicilioStamp, 171 domicilioStamp: $scope.notaPedido.domicilioStamp,
172 estado: 0, 172 estado: 0,
173 total: $scope.getTotal() 173 total: $scope.getTotal()
174 }; 174 };
175 crearNotaPedidoService.crearNotaPedido(notaPedido).then( 175 crearNotaPedidoService.crearNotaPedido(notaPedido).then(
176 function(data) { 176 function(data) {
177 // Al guardar los datos de la nota de pedido logueamos la
178 // actividad para su seguimiento.
179 focaSeguimientoService.guardarPosicion(
180 $scope.notaPedido.vendedor.codigo,
181 'Nota de pedido',
182 'Nº: ' + $filter('comprobante')([
183 $scope.puntoVenta,
184 $scope.comprobante
185 ])
186 );
177 notaPedidoBusinessService.addArticulos($scope.articulosTabla, 187 notaPedidoBusinessService.addArticulos($scope.articulosTabla,
178 data.data.id, $scope.notaPedido.cotizacion.VENDEDOR); 188 data.data.id, $scope.notaPedido.cotizacion.VENDEDOR);
179 var plazos = $scope.plazosPagos; 189 var plazos = $scope.plazosPagos;
180 190
181 for(var j = 0; j < plazos.length; j++) { 191 for(var j = 0; j < plazos.length; j++) {
182 var json = { 192 var json = {
183 idPedido: data.data.id, 193 idPedido: data.data.id,
184 dias: plazos[j].dias 194 dias: plazos[j].dias
185 }; 195 };
186 crearNotaPedidoService.crearPlazosParaNotaPedido(json); 196 crearNotaPedidoService.crearPlazosParaNotaPedido(json);
187 } 197 }
188 notaPedidoBusinessService.addEstado(data.data.id, 198 notaPedidoBusinessService.addEstado(data.data.id,
189 $scope.notaPedido.vendedor.codigo); 199 $scope.notaPedido.vendedor.codigo);
190 200
191 focaModalService.alert('Nota pedido creada'); 201 focaModalService.alert('Nota pedido creada');
192 $scope.cabecera = []; 202 $scope.cabecera = [];
193 addCabecera('Moneda:', $scope.notaPedido.moneda.detalle); 203 addCabecera('Moneda:', $scope.notaPedido.moneda.detalle);
194 addCabecera( 204 addCabecera(
195 'Fecha cotizacion:', 205 'Fecha cotizacion:',
196 $filter('date')($scope.notaPedido.cotizacion.FECHA, 'dd/MM/yyyy') 206 $filter('date')($scope.notaPedido.cotizacion.FECHA, 'dd/MM/yyyy')
197 ); 207 );
198 addCabecera('Cotizacion:', $scope.notaPedido.cotizacion.VENDEDOR); 208 addCabecera('Cotizacion:', $scope.notaPedido.cotizacion.VENDEDOR);
199 $scope.notaPedido.vendedor = {}; 209 $scope.notaPedido.vendedor = {};
200 $scope.notaPedido.cliente = {}; 210 $scope.notaPedido.cliente = {};
201 $scope.notaPedido.proveedor = {}; 211 $scope.notaPedido.proveedor = {};
202 $scope.notaPedido.domicilio = {}; 212 $scope.notaPedido.domicilio = {};
203 $scope.notaPedido.flete = null; 213 $scope.notaPedido.flete = null;
204 $scope.notaPedido.fob = null; 214 $scope.notaPedido.fob = null;
205 $scope.notaPedido.bomba = null; 215 $scope.notaPedido.bomba = null;
206 $scope.notaPedido.kilometros = null; 216 $scope.notaPedido.kilometros = null;
207 $scope.articulosTabla = []; 217 $scope.articulosTabla = [];
208 }, 218 },
209 function(error) { 219 function(error) {
210 focaModalService.alert('Hubo un error al crear la nota de pedido'); 220 focaModalService.alert('Hubo un error al crear la nota de pedido');
211 console.info(error); 221 console.info(error);
212 } 222 }
213 ); 223 );
214 }; 224 };
215 225
216 $scope.seleccionarArticulo = function() { 226 $scope.seleccionarArticulo = function() {
217 if ($scope.idLista === undefined) { 227 if ($scope.idLista === undefined) {
218 focaModalService.alert( 228 focaModalService.alert(
219 'Primero seleccione una lista de precio y condicion'); 229 'Primero seleccione una lista de precio y condicion');
220 return; 230 return;
221 } 231 }
222 var modalInstance = $uibModal.open( 232 var modalInstance = $uibModal.open(
223 { 233 {
224 ariaLabelledBy: 'Busqueda de Productos', 234 ariaLabelledBy: 'Busqueda de Productos',
225 templateUrl: 'modal-busqueda-productos.html', 235 templateUrl: 'modal-busqueda-productos.html',
226 controller: 'modalBusquedaProductosCtrl', 236 controller: 'modalBusquedaProductosCtrl',
227 resolve: { 237 resolve: {
228 parametroProducto: { 238 parametroProducto: {
229 idLista: $scope.idLista, 239 idLista: $scope.idLista,
230 cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, 240 cotizacion: $scope.notaPedido.cotizacion.VENDEDOR,
231 simbolo: $scope.notaPedido.moneda.simbolo 241 simbolo: $scope.notaPedido.moneda.simbolo
232 } 242 }
233 }, 243 },
234 size: 'lg' 244 size: 'lg'
235 } 245 }
236 ); 246 );
237 modalInstance.result.then( 247 modalInstance.result.then(
238 function(producto) { 248 function(producto) {
239 var newArt = 249 var newArt =
240 { 250 {
241 id: 0, 251 id: 0,
242 codigo: producto.codigo, 252 codigo: producto.codigo,
243 sector: producto.sector, 253 sector: producto.sector,
244 sectorCodigo: producto.sector + '-' + producto.codigo, 254 sectorCodigo: producto.sector + '-' + producto.codigo,
245 descripcion: producto.descripcion, 255 descripcion: producto.descripcion,
246 item: $scope.articulosTabla.length + 1, 256 item: $scope.articulosTabla.length + 1,
247 nombre: producto.descripcion, 257 nombre: producto.descripcion,
248 precio: parseFloat(producto.precio.toFixed(4)), 258 precio: parseFloat(producto.precio.toFixed(4)),
249 costoUnitario: producto.costo, 259 costoUnitario: producto.costo,
250 editCantidad: false, 260 editCantidad: false,
251 editPrecio: false, 261 editPrecio: false,
252 rubro: producto.CodRub, 262 rubro: producto.CodRub,
253 exentoUnitario: producto.precio, 263 exentoUnitario: producto.precio,
254 ivaUnitario: producto.IMPIVA, 264 ivaUnitario: producto.IMPIVA,
255 impuestoInternoUnitario: producto.ImpInt, 265 impuestoInternoUnitario: producto.ImpInt,
256 impuestoInterno1Unitario: producto.ImpInt2, 266 impuestoInterno1Unitario: producto.ImpInt2,
257 impuestoInterno2Unitario: producto.ImpInt3, 267 impuestoInterno2Unitario: producto.ImpInt3,
258 precioLista: producto.precio, 268 precioLista: producto.precio,
259 combustible: 1, 269 combustible: 1,
260 facturado: 0 270 facturado: 0
261 }; 271 };
262 $scope.articuloACargar = newArt; 272 $scope.articuloACargar = newArt;
263 $scope.cargando = false; 273 $scope.cargando = false;
264 }, function() { 274 }, function() {
265 // funcion ejecutada cuando se cancela el modal 275 // funcion ejecutada cuando se cancela el modal
266 } 276 }
267 ); 277 );
268 }; 278 };
269 279
270 $scope.seleccionarVendedor = function() { 280 $scope.seleccionarVendedor = function() {
271 var modalInstance = $uibModal.open( 281 var modalInstance = $uibModal.open(
272 { 282 {
273 ariaLabelledBy: 'Busqueda de Vendedores', 283 ariaLabelledBy: 'Busqueda de Vendedores',
274 templateUrl: 'modal-vendedores.html', 284 templateUrl: 'modal-vendedores.html',
275 controller: 'modalVendedoresCtrl', 285 controller: 'modalVendedoresCtrl',
276 size: 'lg' 286 size: 'lg'
277 } 287 }
278 ); 288 );
279 modalInstance.result.then( 289 modalInstance.result.then(
280 function(vendedor) { 290 function(vendedor) {
281 addCabecera('Vendedor:', vendedor.NomVen); 291 addCabecera('Vendedor:', vendedor.NomVen);
282 $scope.notaPedido.vendedor.codigo = vendedor.CodVen; 292 $scope.notaPedido.vendedor.codigo = vendedor.CodVen;
283 }, function() { 293 }, function() {
284 294
285 } 295 }
286 ); 296 );
287 }; 297 };
288 298
289 $scope.seleccionarProveedor = function() { 299 $scope.seleccionarProveedor = function() {
290 var modalInstance = $uibModal.open( 300 var modalInstance = $uibModal.open(
291 { 301 {
292 ariaLabelledBy: 'Busqueda de Proveedor', 302 ariaLabelledBy: 'Busqueda de Proveedor',
293 templateUrl: 'modal-proveedor.html', 303 templateUrl: 'modal-proveedor.html',
294 controller: 'focaModalProveedorCtrl', 304 controller: 'focaModalProveedorCtrl',
295 size: 'lg', 305 size: 'lg',
296 resolve: { 306 resolve: {
297 transportista: function() { 307 transportista: function() {
298 return false; 308 return false;
299 } 309 }
300 } 310 }
301 } 311 }
302 ); 312 );
303 modalInstance.result.then( 313 modalInstance.result.then(
304 function(proveedor) { 314 function(proveedor) {
305 $scope.notaPedido.proveedor.codigo = proveedor.COD; 315 $scope.notaPedido.proveedor.codigo = proveedor.COD;
306 addCabecera('Proveedor:', proveedor.NOM); 316 addCabecera('Proveedor:', proveedor.NOM);
307 }, function() { 317 }, function() {
308 318
309 } 319 }
310 ); 320 );
311 }; 321 };
312 322
313 $scope.seleccionarCliente = function() { 323 $scope.seleccionarCliente = function() {
314 324
315 var modalInstance = $uibModal.open( 325 var modalInstance = $uibModal.open(
316 { 326 {
317 ariaLabelledBy: 'Busqueda de Cliente', 327 ariaLabelledBy: 'Busqueda de Cliente',
318 templateUrl: 'foca-busqueda-cliente-modal.html', 328 templateUrl: 'foca-busqueda-cliente-modal.html',
319 controller: 'focaBusquedaClienteModalController', 329 controller: 'focaBusquedaClienteModalController',
320 size: 'lg' 330 size: 'lg'
321 } 331 }
322 ); 332 );
323 modalInstance.result.then( 333 modalInstance.result.then(
324 function(cliente) { 334 function(cliente) {
325 $scope.abrirModalDomicilios(cliente); 335 $scope.abrirModalDomicilios(cliente);
326 }, function() { 336 }, function() {
327 337
328 } 338 }
329 ); 339 );
330 }; 340 };
331 341
332 $scope.abrirModalDomicilios = function(cliente) { 342 $scope.abrirModalDomicilios = function(cliente) {
333 var modalInstanceDomicilio = $uibModal.open( 343 var modalInstanceDomicilio = $uibModal.open(
334 { 344 {
335 ariaLabelledBy: 'Busqueda de Domicilios', 345 ariaLabelledBy: 'Busqueda de Domicilios',
336 templateUrl: 'modal-domicilio.html', 346 templateUrl: 'modal-domicilio.html',
337 controller: 'focaModalDomicilioController', 347 controller: 'focaModalDomicilioController',
338 resolve: { idCliente: function() { return cliente.cod; }}, 348 resolve: { idCliente: function() { return cliente.cod; }},
339 size: 'lg', 349 size: 'lg',
340 } 350 }
341 ); 351 );
342 modalInstanceDomicilio.result.then( 352 modalInstanceDomicilio.result.then(
343 function(domicilio) { 353 function(domicilio) {
344 $scope.notaPedido.domicilio.id = domicilio.id; 354 $scope.notaPedido.domicilio.id = domicilio.id;
345 $scope.notaPedido.cliente = cliente; 355 $scope.notaPedido.cliente = cliente;
346 addCabecera('Cliente:', cliente.nom); 356 addCabecera('Cliente:', cliente.nom);
347 var domicilioStamp = 357 var domicilioStamp =
348 domicilio.Calle + ' ' + domicilio.Numero + ', ' + 358 domicilio.Calle + ' ' + domicilio.Numero + ', ' +
349 domicilio.Localidad + ', ' + domicilio.Provincia; 359 domicilio.Localidad + ', ' + domicilio.Provincia;
350 $scope.notaPedido.domicilioStamp = domicilioStamp; 360 $scope.notaPedido.domicilioStamp = domicilioStamp;
351 addCabecera('Domicilio:', domicilioStamp); 361 addCabecera('Domicilio:', domicilioStamp);
352 }, function() { 362 }, function() {
353 $scope.seleccionarCliente(); 363 $scope.seleccionarCliente();
354 return; 364 return;
355 } 365 }
356 ); 366 );
357 }; 367 };
358 368
359 $scope.mostrarFichaCliente = function() { 369 $scope.mostrarFichaCliente = function() {
360 $uibModal.open( 370 $uibModal.open(
361 { 371 {
362 ariaLabelledBy: 'Datos del Cliente', 372 ariaLabelledBy: 'Datos del Cliente',
363 templateUrl: 'foca-crear-nota-pedido-ficha-cliente.html', 373 templateUrl: 'foca-crear-nota-pedido-ficha-cliente.html',
364 controller: 'focaCrearNotaPedidoFichaClienteController', 374 controller: 'focaCrearNotaPedidoFichaClienteController',
365 size: 'lg' 375 size: 'lg'
366 } 376 }
367 ); 377 );
368 }; 378 };
369 379
370 $scope.getTotal = function() { 380 $scope.getTotal = function() {
371 var total = 0; 381 var total = 0;
372 var arrayTempArticulos = $scope.articulosTabla; 382 var arrayTempArticulos = $scope.articulosTabla;
373 for (var i = 0; i < arrayTempArticulos.length; i++) { 383 for (var i = 0; i < arrayTempArticulos.length; i++) {
374 total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; 384 total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad;
375 } 385 }
376 return parseFloat(total.toFixed(2)); 386 return parseFloat(total.toFixed(2));
377 }; 387 };
378 388
379 $scope.getSubTotal = function() { 389 $scope.getSubTotal = function() {
380 if($scope.articuloACargar) { 390 if($scope.articuloACargar) {
381 return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; 391 return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad;
382 } 392 }
383 }; 393 };
384 394
385 $scope.abrirModalListaPrecio = function() { 395 $scope.abrirModalListaPrecio = function() {
386 var modalInstance = $uibModal.open( 396 var modalInstance = $uibModal.open(
387 { 397 {
388 ariaLabelledBy: 'Busqueda de Precio Condición', 398 ariaLabelledBy: 'Busqueda de Precio Condición',
389 templateUrl: 'modal-precio-condicion.html', 399 templateUrl: 'modal-precio-condicion.html',
390 controller: 'focaModalPrecioCondicionController', 400 controller: 'focaModalPrecioCondicionController',
391 size: 'lg' 401 size: 'lg'
392 } 402 }
393 ); 403 );
394 modalInstance.result.then( 404 modalInstance.result.then(
395 function(precioCondicion) { 405 function(precioCondicion) {
396 var cabecera = ''; 406 var cabecera = '';
397 var plazosConcat = ''; 407 var plazosConcat = '';
398 if(!Array.isArray(precioCondicion)) { 408 if(!Array.isArray(precioCondicion)) {
399 $scope.notaPedido.idPrecioCondicion = precioCondicion.id; 409 $scope.notaPedido.idPrecioCondicion = precioCondicion.id;
400 $scope.plazosPagos = precioCondicion.plazoPago; 410 $scope.plazosPagos = precioCondicion.plazoPago;
401 $scope.idLista = precioCondicion.idListaPrecio; 411 $scope.idLista = precioCondicion.idListaPrecio;
402 for(var i = 0; i < precioCondicion.plazoPago.length; i++) { 412 for(var i = 0; i < precioCondicion.plazoPago.length; i++) {
403 plazosConcat += precioCondicion.plazoPago[i].dias + ' '; 413 plazosConcat += precioCondicion.plazoPago[i].dias + ' ';
404 } 414 }
405 cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); 415 cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim();
406 } else { //Cuando se ingresan los plazos manualmente 416 } else { //Cuando se ingresan los plazos manualmente
407 $scope.notaPedido.idPrecioCondicion = 0; 417 $scope.notaPedido.idPrecioCondicion = 0;
408 $scope.idLista = -1; //-1, el modal productos busca todos los productos 418 $scope.idLista = -1; //-1, el modal productos busca todos los productos
409 $scope.plazosPagos = precioCondicion; 419 $scope.plazosPagos = precioCondicion;
410 for(var j = 0; j < precioCondicion.length; j++) { 420 for(var j = 0; j < precioCondicion.length; j++) {
411 plazosConcat += precioCondicion[j].dias + ' '; 421 plazosConcat += precioCondicion[j].dias + ' ';
412 } 422 }
413 cabecera = 'Ingreso manual ' + plazosConcat.trim(); 423 cabecera = 'Ingreso manual ' + plazosConcat.trim();
414 } 424 }
415 $scope.articulosTabla = []; 425 $scope.articulosTabla = [];
416 addCabecera('Precios y condiciones:', cabecera); 426 addCabecera('Precios y condiciones:', cabecera);
417 }, function() { 427 }, function() {
418 428
419 } 429 }
420 ); 430 );
421 }; 431 };
422 432
423 $scope.abrirModalFlete = function() { 433 $scope.abrirModalFlete = function() {
424 var modalInstance = $uibModal.open( 434 var modalInstance = $uibModal.open(
425 { 435 {
426 ariaLabelledBy: 'Busqueda de Flete', 436 ariaLabelledBy: 'Busqueda de Flete',
427 templateUrl: 'modal-flete.html', 437 templateUrl: 'modal-flete.html',
428 controller: 'focaModalFleteController', 438 controller: 'focaModalFleteController',
429 size: 'lg', 439 size: 'lg',
430 resolve: { 440 resolve: {
431 parametrosFlete: 441 parametrosFlete:
432 function() { 442 function() {
433 return { 443 return {
434 flete: $scope.notaPedido.flete ? '1' : 444 flete: $scope.notaPedido.flete ? '1' :
435 ($scope.notaPedido.fob ? 'FOB' : 445 ($scope.notaPedido.fob ? 'FOB' :
436 ($scope.notaPedido.flete === undefined ? null : '0')), 446 ($scope.notaPedido.flete === undefined ? null : '0')),
437 bomba: $scope.notaPedido.bomba ? '1' : 447 bomba: $scope.notaPedido.bomba ? '1' :
438 ($scope.notaPedido.bomba === undefined ? null : '0'), 448 ($scope.notaPedido.bomba === undefined ? null : '0'),
439 kilometros: $scope.notaPedido.kilometros 449 kilometros: $scope.notaPedido.kilometros
440 }; 450 };
441 } 451 }
442 } 452 }
443 } 453 }
444 ); 454 );
445 modalInstance.result.then( 455 modalInstance.result.then(
446 function(datos) { 456 function(datos) {
447 $scope.notaPedido.flete = datos.flete; 457 $scope.notaPedido.flete = datos.flete;
448 $scope.notaPedido.fob = datos.FOB; 458 $scope.notaPedido.fob = datos.FOB;
449 $scope.notaPedido.bomba = datos.bomba; 459 $scope.notaPedido.bomba = datos.bomba;
450 $scope.notaPedido.kilometros = datos.kilometros; 460 $scope.notaPedido.kilometros = datos.kilometros;
451 461
452 addCabecera('Flete:', datos.flete ? 'Si' : 462 addCabecera('Flete:', datos.flete ? 'Si' :
453 ($scope.notaPedido.fob ? 'FOB' : 'No')); 463 ($scope.notaPedido.fob ? 'FOB' : 'No'));
454 if(datos.flete) { 464 if(datos.flete) {
455 addCabecera('Bomba:', datos.bomba ? 'Si' : 'No'); 465 addCabecera('Bomba:', datos.bomba ? 'Si' : 'No');
456 addCabecera('Kilometros:', datos.kilometros); 466 addCabecera('Kilometros:', datos.kilometros);
457 } else { 467 } else {
458 removeCabecera('Bomba:'); 468 removeCabecera('Bomba:');
459 removeCabecera('Kilometros:'); 469 removeCabecera('Kilometros:');
460 $scope.notaPedido.fob = false; 470 $scope.notaPedido.fob = false;
461 $scope.notaPedido.bomba = false; 471 $scope.notaPedido.bomba = false;
462 $scope.notaPedido.kilometros = null; 472 $scope.notaPedido.kilometros = null;
463 } 473 }
464 }, function() { 474 }, function() {
465 475
466 } 476 }
467 ); 477 );
468 }; 478 };
469 479
470 $scope.abrirModalMoneda = function() { 480 $scope.abrirModalMoneda = function() {
471 var modalInstance = $uibModal.open( 481 var modalInstance = $uibModal.open(
472 { 482 {
473 ariaLabelledBy: 'Busqueda de Moneda', 483 ariaLabelledBy: 'Busqueda de Moneda',
474 templateUrl: 'modal-moneda.html', 484 templateUrl: 'modal-moneda.html',
475 controller: 'focaModalMonedaController', 485 controller: 'focaModalMonedaController',
476 size: 'lg' 486 size: 'lg'
477 } 487 }
478 ); 488 );
479 modalInstance.result.then( 489 modalInstance.result.then(
480 function(moneda) { 490 function(moneda) {
481 $scope.abrirModalCotizacion(moneda); 491 $scope.abrirModalCotizacion(moneda);
482 }, function() { 492 }, function() {
483 493
484 } 494 }
485 ); 495 );
486 }; 496 };
487 497
488 $scope.abrirModalCotizacion = function(moneda) { 498 $scope.abrirModalCotizacion = function(moneda) {
489 var modalInstance = $uibModal.open( 499 var modalInstance = $uibModal.open(
490 { 500 {
491 ariaLabelledBy: 'Busqueda de Cotización', 501 ariaLabelledBy: 'Busqueda de Cotización',
492 templateUrl: 'modal-cotizacion.html', 502 templateUrl: 'modal-cotizacion.html',
493 controller: 'focaModalCotizacionController', 503 controller: 'focaModalCotizacionController',
494 size: 'lg', 504 size: 'lg',
495 resolve: {idMoneda: function() {return moneda.ID;}} 505 resolve: {idMoneda: function() {return moneda.ID;}}
496 } 506 }
497 ); 507 );
498 modalInstance.result.then( 508 modalInstance.result.then(
499 function(cotizacion) { 509 function(cotizacion) {
500 var articulosTablaTemp = $scope.articulosTabla; 510 var articulosTablaTemp = $scope.articulosTabla;
501 for(var i = 0; i < articulosTablaTemp.length; i++) { 511 for(var i = 0; i < articulosTablaTemp.length; i++) {
502 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * 512 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio *
503 $scope.notaPedido.cotizacion.VENDEDOR; 513 $scope.notaPedido.cotizacion.VENDEDOR;
504 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / 514 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio /
505 cotizacion.VENDEDOR; 515 cotizacion.VENDEDOR;
506 } 516 }
507 $scope.articulosTabla = articulosTablaTemp; 517 $scope.articulosTabla = articulosTablaTemp;
508 $scope.notaPedido.moneda = { 518 $scope.notaPedido.moneda = {
509 id: moneda.ID, 519 id: moneda.ID,
510 detalle: moneda.DETALLE, 520 detalle: moneda.DETALLE,
511 simbolo: moneda.SIMBOLO 521 simbolo: moneda.SIMBOLO
512 }; 522 };
513 $scope.notaPedido.cotizacion = cotizacion; 523 $scope.notaPedido.cotizacion = cotizacion;
514 addCabecera('Moneda:', moneda.DETALLE); 524 addCabecera('Moneda:', moneda.DETALLE);
515 addCabecera( 525 addCabecera(
516 'Fecha cotizacion:', 526 'Fecha cotizacion:',
517 $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') 527 $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy')
518 ); 528 );
519 addCabecera('Cotizacion:', cotizacion.VENDEDOR); 529 addCabecera('Cotizacion:', cotizacion.VENDEDOR);
520 }, function() { 530 }, function() {
521 531
522 } 532 }
523 ); 533 );
524 }; 534 };
525 535
526 $scope.agregarATabla = function(key) { 536 $scope.agregarATabla = function(key) {
527 if(key === 13) { 537 if(key === 13) {
528 if($scope.articuloACargar.cantidad === undefined || 538 if($scope.articuloACargar.cantidad === undefined ||
529 $scope.articuloACargar.cantidad === 0 || 539 $scope.articuloACargar.cantidad === 0 ||
530 $scope.articuloACargar.cantidad === null ) { 540 $scope.articuloACargar.cantidad === null ) {
531 focaModalService.alert('El valor debe ser al menos 1'); 541 focaModalService.alert('El valor debe ser al menos 1');
532 return; 542 return;
533 } 543 }
534 delete $scope.articuloACargar.sectorCodigo; 544 delete $scope.articuloACargar.sectorCodigo;
535 $scope.articulosTabla.push($scope.articuloACargar); 545 $scope.articulosTabla.push($scope.articuloACargar);
536 $scope.cargando = true; 546 $scope.cargando = true;
537 } 547 }
538 }; 548 };
539 549
540 $scope.quitarArticulo = function(key) { 550 $scope.quitarArticulo = function(key) {
541 $scope.articulosTabla.splice(key, 1); 551 $scope.articulosTabla.splice(key, 1);
542 }; 552 };
543 553
544 $scope.editarArticulo = function(key, articulo) { 554 $scope.editarArticulo = function(key, articulo) {
545 if(key === 13) { 555 if(key === 13) {
546 if(articulo.cantidad === null || articulo.cantidad === 0 || 556 if(articulo.cantidad === null || articulo.cantidad === 0 ||
547 articulo.cantidad === undefined) { 557 articulo.cantidad === undefined) {
548 focaModalService.alert('El valor debe ser al menos 1'); 558 focaModalService.alert('El valor debe ser al menos 1');
549 return; 559 return;
550 } 560 }
551 articulo.editCantidad = false; 561 articulo.editCantidad = false;
552 articulo.editPrecio = false; 562 articulo.editPrecio = false;
553 } 563 }
554 }; 564 };
555 565
556 $scope.cambioEdit = function(articulo, propiedad) { 566 $scope.cambioEdit = function(articulo, propiedad) {
557 if(propiedad === 'cantidad') { 567 if(propiedad === 'cantidad') {
558 articulo.editCantidad = true; 568 articulo.editCantidad = true;
559 } else if(propiedad === 'precio') { 569 } else if(propiedad === 'precio') {
560 articulo.editPrecio = true; 570 articulo.editPrecio = true;
561 } 571 }
562 }; 572 };
563 573
564 $scope.limpiarFlete = function() { 574 $scope.limpiarFlete = function() {
565 $scope.notaPedido.fleteNombre = ''; 575 $scope.notaPedido.fleteNombre = '';
566 $scope.notaPedido.chofer = ''; 576 $scope.notaPedido.chofer = '';
567 $scope.notaPedido.vehiculo = ''; 577 $scope.notaPedido.vehiculo = '';
568 $scope.notaPedido.kilometros = ''; 578 $scope.notaPedido.kilometros = '';
569 $scope.notaPedido.costoUnitarioKmFlete = ''; 579 $scope.notaPedido.costoUnitarioKmFlete = '';
570 $scope.choferes = ''; 580 $scope.choferes = '';
571 $scope.vehiculos = ''; 581 $scope.vehiculos = '';
572 }; 582 };
573 583
574 $scope.limpiarPantalla = function() { 584 $scope.limpiarPantalla = function() {
575 $scope.limpiarFlete(); 585 $scope.limpiarFlete();
576 $scope.notaPedido.flete = '0'; 586 $scope.notaPedido.flete = '0';
577 $scope.notaPedido.bomba = '0'; 587 $scope.notaPedido.bomba = '0';
578 $scope.notaPedido.precioCondicion = ''; 588 $scope.notaPedido.precioCondicion = '';
579 $scope.articulosTabla = []; 589 $scope.articulosTabla = [];
580 $scope.notaPedido.vendedor.nombre = ''; 590 $scope.notaPedido.vendedor.nombre = '';
581 $scope.notaPedido.cliente = {nombre: ''}; 591 $scope.notaPedido.cliente = {nombre: ''};
582 $scope.notaPedido.domicilio = {dom: ''}; 592 $scope.notaPedido.domicilio = {dom: ''};
583 $scope.domiciliosCliente = []; 593 $scope.domiciliosCliente = [];
584 }; 594 };
585 595
586 $scope.resetFilter = function() { 596 $scope.resetFilter = function() {
587 $scope.articuloACargar = {}; 597 $scope.articuloACargar = {};
588 $scope.cargando = true; 598 $scope.cargando = true;
589 }; 599 };
590 //Recibe aviso si el teclado está en uso 600 //Recibe aviso si el teclado está en uso
591 $rootScope.$on('usarTeclado', function(event, data) { 601 $rootScope.$on('usarTeclado', function(event, data) {
592 if(data) { 602 if(data) {
593 $scope.mostrarTeclado = true; 603 $scope.mostrarTeclado = true;
594 return; 604 return;
595 } 605 }
596 $scope.mostrarTeclado = false; 606 $scope.mostrarTeclado = false;
597 }); 607 });
598 608
599 $scope.selectFocus = function($event) { 609 $scope.selectFocus = function($event) {
600 // Si el teclado esta en uso no selecciona el valor 610 // Si el teclado esta en uso no selecciona el valor
601 if($scope.mostrarTeclado) { 611 if($scope.mostrarTeclado) {
602 return; 612 return;
603 } 613 }
604 $event.target.select(); 614 $event.target.select();
605 }; 615 };
606 616
607 $scope.salir = function() { 617 $scope.salir = function() {
608 $location.path('/'); 618 $location.path('/');
609 }; 619 };
610 620
611 $scope.parsearATexto = function(articulo) { 621 $scope.parsearATexto = function(articulo) {
612 articulo.cantidad = parseFloat(articulo.cantidad); 622 articulo.cantidad = parseFloat(articulo.cantidad);
613 articulo.precio = parseFloat(articulo.precio); 623 articulo.precio = parseFloat(articulo.precio);
614 }; 624 };
615 625
616 function addCabecera(label, valor) { 626 function addCabecera(label, valor) {
617 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); 627 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true);
618 if(propiedad.length === 1) { 628 if(propiedad.length === 1) {
619 propiedad[0].valor = valor; 629 propiedad[0].valor = valor;
620 } else { 630 } else {
621 $scope.cabecera.push({label: label, valor: valor}); 631 $scope.cabecera.push({label: label, valor: valor});
622 } 632 }
623 } 633 }
624 634
625 function removeCabecera(label) { 635 function removeCabecera(label) {
626 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); 636 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true);
627 if(propiedad.length === 1) { 637 if(propiedad.length === 1) {
628 $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); 638 $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1);
629 } 639 }
630 } 640 }
631 641
632 function rellenar(relleno, longitud) { 642 function rellenar(relleno, longitud) {
633 relleno = '' + relleno; 643 relleno = '' + relleno;
634 while (relleno.length < longitud) { 644 while (relleno.length < longitud) {
635 relleno = '0' + relleno; 645 relleno = '0' + relleno;
636 } 646 }
637 647
638 return relleno; 648 return relleno;
639 } 649 }
640 } 650 }
641 ] 651 ]
642 ) 652 )
643 .controller('notaPedidoListaCtrl', [ 653 .controller('notaPedidoListaCtrl', [
644 '$scope', 654 '$scope',
645 'crearNotaPedidoService', 655 'crearNotaPedidoService',
646 '$location', 656 '$location',
647 function($scope, crearNotaPedidoService, $location) { 657 function($scope, crearNotaPedidoService, $location) {
648 crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { 658 crearNotaPedidoService.obtenerNotaPedido().then(function(datos) {
649 $scope.notaPedidos = datos.data; 659 $scope.notaPedidos = datos.data;
650 }); 660 });
651 $scope.editar = function(notaPedido) { 661 $scope.editar = function(notaPedido) {
652 crearNotaPedidoService.setNotaPedido(notaPedido); 662 crearNotaPedidoService.setNotaPedido(notaPedido);
653 $location.path('/venta-nota-pedido/abm/'); 663 $location.path('/venta-nota-pedido/abm/');
654 }; 664 };
655 $scope.crearPedido = function() { 665 $scope.crearPedido = function() {
656 crearNotaPedidoService.clearNotaPedido(); 666 crearNotaPedidoService.clearNotaPedido();
657 $location.path('/venta-nota-pedido/abm/'); 667 $location.path('/venta-nota-pedido/abm/');
658 }; 668 };
659 } 669 }
660 ]) 670 ])
661 .controller('focaCrearNotaPedidoFichaClienteController', [ 671 .controller('focaCrearNotaPedidoFichaClienteController', [
662 '$scope', 672 '$scope',
663 'crearNotaPedidoService', 673 'crearNotaPedidoService',
664 '$location', 674 '$location',
665 function($scope, crearNotaPedidoService, $location) { 675 function($scope, crearNotaPedidoService, $location) {
666 crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { 676 crearNotaPedidoService.obtenerNotaPedido().then(function(datos) {
667 $scope.notaPedidos = datos.data; 677 $scope.notaPedidos = datos.data;
668 }); 678 });
669 $scope.editar = function(notaPedido) { 679 $scope.editar = function(notaPedido) {
670 crearNotaPedidoService.setNotaPedido(notaPedido); 680 crearNotaPedidoService.setNotaPedido(notaPedido);
671 $location.path('/venta-nota-pedido/abm/'); 681 $location.path('/venta-nota-pedido/abm/');
672 }; 682 };
673 $scope.crearPedido = function() { 683 $scope.crearPedido = function() {
674 crearNotaPedidoService.clearNotaPedido(); 684 crearNotaPedidoService.clearNotaPedido();
675 $location.path('/venta-nota-pedido/abm/'); 685 $location.path('/venta-nota-pedido/abm/');
676 }; 686 };
677 } 687 }
678 ]); 688 ]);
679 689