Commit 4f377f9fd65420dbf12ef1fe28fb8f5de3b5d582

Authored by Eric Fernandez
Exists in master

Merge branch 'master' of https://debo.suite.repo/modulos-npm/foca-crear-nota-pedido

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