Commit d6d63dae0f47d80bc7e86778eb770ef38c42a672

Authored by Eric Fernandez
Exists in master

Merge branch 'master' into 'master'

Master

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