Commit 8c93aa230a71a6e370bb9b6ef350affbc961005b

Authored by Eric Fernandez
1 parent 8fafa96188
Exists in master

Fix precios según cotización

src/js/businessService.js
1 angular.module('focaCrearNotaPedido') 1 angular.module('focaCrearNotaPedido')
2 .factory('notaPedidoBusinessService', [ 2 .factory('notaPedidoBusinessService', [
3 'crearNotaPedidoService', 3 'crearNotaPedidoService',
4 function(crearNotaPedidoService) { 4 function(crearNotaPedidoService) {
5 return { 5 return {
6 addArticulos: function(articulosNotaPedido, idNotaPedido, cotizacion) { 6 addArticulos: function(articulosNotaPedido, idNotaPedido, cotizacion) {
7 for(var i = 0; i < articulosNotaPedido.length; i++) { 7 for(var i = 0; i < articulosNotaPedido.length; i++) {
8 delete articulosNotaPedido[i].editCantidad; 8 delete articulosNotaPedido[i].editCantidad;
9 delete articulosNotaPedido[i].editPrecio; 9 delete articulosNotaPedido[i].editPrecio;
10 articulosNotaPedido[i].idNotaPedido = idNotaPedido; 10 articulosNotaPedido[i].idNotaPedido = idNotaPedido;
11 articulosNotaPedido[i].precio = articulosNotaPedido[i].precio * cotizacion; 11 articulosNotaPedido[i].precio = articulosNotaPedido[i].precio * cotizacion;
12 crearNotaPedidoService.crearArticulosParaNotaPedido(articulosNotaPedido[i]); 12 crearNotaPedidoService.crearArticulosParaNotaPedido(articulosNotaPedido[i]);
13 } 13 }
14 }, 14 },
15 addEstado: function(idNotaPedido, idVendedor) { 15 addEstado: function(idNotaPedido, idVendedor) {
16 var date = new Date(); 16 var date = new Date();
17 var estado = { 17 var estado = {
18 idNotaPedido: idNotaPedido, 18 idNotaPedido: idNotaPedido,
19 fecha: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) 19 fecha: new Date(date.getTime() - (date.getTimezoneOffset() * 60000))
20 .toISOString().slice(0, 19).replace('T', ' '), 20 .toISOString().slice(0, 19).replace('T', ' '),
21 estado: 0, 21 estado: 0,
22 idVendedor: idVendedor 22 idVendedor: idVendedor
23 }; 23 };
24 crearNotaPedidoService.crearEstadoParaNotaPedido(estado); 24 crearNotaPedidoService.crearEstadoParaNotaPedido(estado);
25 },
26 calcularArticulos: function(articulos, cotizacion) {
27 for(var i = 0; i < articulos.length; i++) {
28 articulos[i].precio = articulos[i].precio / cotizacion;
29 }
25 } 30 }
26 }; 31 };
27 }]); 32 }]);
28 33
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', 'focaSeguimientoService', 4 'focaModalService', 'notaPedidoBusinessService', '$rootScope', 'focaSeguimientoService',
5 function( 5 function(
6 $scope, $uibModal, $location, $filter, crearNotaPedidoService, focaModalService, 6 $scope, $uibModal, $location, $filter, crearNotaPedidoService, focaModalService,
7 notaPedidoBusinessService, $rootScope, focaSeguimientoService 7 notaPedidoBusinessService, $rootScope, focaSeguimientoService
8 ) { 8 ) {
9 $scope.botonera = [ 9 $scope.botonera = [
10 {texto: 'Vendedor', accion: function() { 10 {texto: 'Vendedor', accion: function() {
11 validarNotaRemitada($scope.seleccionarVendedor);}}, 11 validarNotaRemitada($scope.seleccionarVendedor);}},
12 {texto: 'Cliente', accion: function() { 12 {texto: 'Cliente', accion: function() {
13 validarNotaRemitada($scope.seleccionarCliente);}}, 13 validarNotaRemitada($scope.seleccionarCliente);}},
14 {texto: 'Proveedor', accion: function() { 14 {texto: 'Proveedor', accion: function() {
15 validarNotaRemitada($scope.seleccionarProveedor);}}, 15 validarNotaRemitada($scope.seleccionarProveedor);}},
16 {texto: 'Moneda', accion: function() { 16 {texto: 'Moneda', accion: function() {
17 validarNotaRemitada($scope.abrirModalMoneda);}}, 17 validarNotaRemitada($scope.abrirModalMoneda);}},
18 {texto: 'Precios y condiciones', accion: function() { 18 {texto: 'Precios y condiciones', accion: function() {
19 validarNotaRemitada($scope.abrirModalListaPrecio);}}, 19 validarNotaRemitada($scope.abrirModalListaPrecio);}},
20 {texto: 'Flete', accion: function() { 20 {texto: 'Flete', accion: function() {
21 validarNotaRemitada($scope.abrirModalFlete);}}, 21 validarNotaRemitada($scope.abrirModalFlete);}},
22 {texto: '', accion: function() {}}, 22 {texto: '', accion: function() {}},
23 {texto: '', accion: function() {}} 23 {texto: '', accion: function() {}}
24 ]; 24 ];
25 25
26 $scope.datepickerAbierto = false; 26 $scope.datepickerAbierto = false;
27 27
28 $scope.show = false; 28 $scope.show = false;
29 $scope.cargando = true; 29 $scope.cargando = true;
30 $scope.dateOptions = { 30 $scope.dateOptions = {
31 maxDate: new Date(), 31 maxDate: new Date(),
32 minDate: new Date(2010, 0, 1) 32 minDate: new Date(2010, 0, 1)
33 }; 33 };
34 34
35 $scope.notaPedido = { 35 $scope.notaPedido = {
36 id: 0, 36 id: 0,
37 vendedor: {}, 37 vendedor: {},
38 cliente: {}, 38 cliente: {},
39 proveedor: {}, 39 proveedor: {},
40 domicilio: {dom: ''}, 40 domicilio: {dom: ''},
41 moneda: {}, 41 moneda: {},
42 cotizacion: {} 42 cotizacion: {}
43 }; 43 };
44 var monedaPorDefecto; 44 var monedaPorDefecto;
45 //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' 45 //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]'
46 crearNotaPedidoService.getCotizacionByIdMoneda(1).then(function(res) { 46 crearNotaPedidoService.getCotizacionByIdMoneda(1).then(function(res) {
47 monedaPorDefecto = res.data[0]; 47 monedaPorDefecto = res.data[0];
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.CodVen) { 124 if(!$scope.notaPedido.vendedor.CodVen) {
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.COD) { 130 } else if(!$scope.notaPedido.proveedor.COD) {
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.domicilioStamp) {//TODO validar domicilio correcto 147 } else if(!$scope.notaPedido.domicilioStamp) {//TODO validar domicilio correcto
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: $scope.notaPedido.id, 156 id: $scope.notaPedido.id,
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.CodVen, 159 idVendedor: $scope.notaPedido.vendedor.CodVen,
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.COD, 163 idProveedor: $scope.notaPedido.proveedor.COD,
164 idDomicilio: $scope.notaPedido.domicilio.id, 164 //idDomicilio: $scope.notaPedido.domicilio.id,TODO GUARDAR 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 domicilioStamp: $scope.notaPedido.domicilioStamp,
173 estado: 0, 173 estado: 0,
174 total: $scope.getTotal() 174 total: $scope.getTotal()
175 }; 175 };
176 crearNotaPedidoService.crearNotaPedido(notaPedido).then( 176 crearNotaPedidoService.crearNotaPedido(notaPedido).then(
177 function(data) { 177 function(data) {
178 // Al guardar los datos de la nota de pedido logueamos la 178 // Al guardar los datos de la nota de pedido logueamos la
179 // actividad para su seguimiento. 179 // actividad para su seguimiento.
180 focaSeguimientoService.guardarPosicion( 180 focaSeguimientoService.guardarPosicion(
181 $scope.notaPedido.vendedor.CodVen, 181 $scope.notaPedido.vendedor.CodVen,
182 'Nota de pedido', 182 'Nota de pedido',
183 'Nº: ' + $filter('comprobante')([ 183 'Nº: ' + $filter('comprobante')([
184 $scope.puntoVenta, 184 $scope.puntoVenta,
185 $scope.comprobante 185 $scope.comprobante
186 ]) + '<br/>' + 186 ]) + '<br/>' +
187 'Vendedor: ' + $scope.notaPedido.vendedor.NomVen + '<br/>' + 187 'Vendedor: ' + $scope.notaPedido.vendedor.NomVen + '<br/>' +
188 'Total: ' + $filter('currency')($scope.getTotal()) 188 'Total: ' + $filter('currency')($scope.getTotal())
189 ); 189 );
190 notaPedidoBusinessService.addArticulos($scope.articulosTabla, 190 notaPedidoBusinessService.addArticulos($scope.articulosTabla,
191 data.data.id, $scope.notaPedido.cotizacion.VENDEDOR); 191 data.data.id, $scope.notaPedido.cotizacion.VENDEDOR);
192 var plazos = $scope.plazosPagos; 192 var plazos = $scope.plazosPagos;
193 193
194 for(var j = 0; j < plazos.length; j++) { 194 for(var j = 0; j < plazos.length; j++) {
195 var json = { 195 var json = {
196 idPedido: data.data.id, 196 idPedido: data.data.id,
197 dias: plazos[j].dias 197 dias: plazos[j].dias
198 }; 198 };
199 crearNotaPedidoService.crearPlazosParaNotaPedido(json); 199 crearNotaPedidoService.crearPlazosParaNotaPedido(json);
200 } 200 }
201 notaPedidoBusinessService.addEstado(data.data.id, 201 notaPedidoBusinessService.addEstado(data.data.id,
202 $scope.notaPedido.vendedor.CodVen); 202 $scope.notaPedido.vendedor.CodVen);
203 203
204 focaModalService.alert('Nota pedido creada'); 204 focaModalService.alert('Nota pedido creada');
205 $scope.cabecera = []; 205 $scope.cabecera = [];
206 addCabecera('Moneda:', $scope.notaPedido.moneda.detalle); 206 addCabecera('Moneda:', $scope.notaPedido.moneda.detalle);
207 addCabecera( 207 addCabecera(
208 'Fecha cotizacion:', 208 'Fecha cotizacion:',
209 $filter('date')($scope.notaPedido.cotizacion.FECHA, 'dd/MM/yyyy') 209 $filter('date')($scope.notaPedido.cotizacion.FECHA, 'dd/MM/yyyy')
210 ); 210 );
211 addCabecera('Cotizacion:', $scope.notaPedido.cotizacion.VENDEDOR); 211 addCabecera('Cotizacion:', $scope.notaPedido.cotizacion.VENDEDOR);
212 crearNotaPedidoService.getNumeroNotaPedido().then( 212 crearNotaPedidoService.getNumeroNotaPedido().then(
213 function(res) { 213 function(res) {
214 $scope.puntoVenta = rellenar(res.data.sucursal, 4); 214 $scope.puntoVenta = rellenar(res.data.sucursal, 4);
215 $scope.comprobante = rellenar(res.data.numeroNotaPedido, 8); 215 $scope.comprobante = rellenar(res.data.numeroNotaPedido, 8);
216 }, 216 },
217 function(err) { 217 function(err) {
218 focaModalService.alert( 218 focaModalService.alert(
219 'La terminal no esta configurada correctamente'); 219 'La terminal no esta configurada correctamente');
220 console.info(err); 220 console.info(err);
221 } 221 }
222 ); 222 );
223 $scope.notaPedido.vendedor = {}; 223 $scope.notaPedido.vendedor = {};
224 $scope.notaPedido.cliente = {}; 224 $scope.notaPedido.cliente = {};
225 $scope.notaPedido.proveedor = {}; 225 $scope.notaPedido.proveedor = {};
226 $scope.notaPedido.domicilio = {}; 226 $scope.notaPedido.domicilio = {};
227 $scope.notaPedido.flete = null; 227 $scope.notaPedido.flete = null;
228 $scope.notaPedido.fob = null; 228 $scope.notaPedido.fob = null;
229 $scope.notaPedido.bomba = null; 229 $scope.notaPedido.bomba = null;
230 $scope.notaPedido.kilometros = null; 230 $scope.notaPedido.kilometros = null;
231 $scope.articulosTabla = []; 231 $scope.articulosTabla = [];
232 }, 232 },
233 function(error) { 233 function(error) {
234 focaModalService.alert('Hubo un error al crear la nota de pedido'); 234 focaModalService.alert('Hubo un error al crear la nota de pedido');
235 console.info(error); 235 console.info(error);
236 } 236 }
237 ); 237 );
238 }; 238 };
239 239
240 $scope.seleccionarNotaPedido = function() { 240 $scope.seleccionarNotaPedido = function() {
241 var modalInstance = $uibModal.open( 241 var modalInstance = $uibModal.open(
242 { 242 {
243 ariaLabelledBy: 'Busqueda de Nota de Pedido', 243 ariaLabelledBy: 'Busqueda de Nota de Pedido',
244 templateUrl: 'foca-modal-nota-pedido.html', 244 templateUrl: 'foca-modal-nota-pedido.html',
245 controller: 'focaModalNotaPedidoController', 245 controller: 'focaModalNotaPedidoController',
246 size: 'lg', 246 size: 'lg',
247 resolve: {usadoPor: function(){return 'notaPedido';}} 247 resolve: {usadoPor: function(){return 'notaPedido';}}
248 } 248 }
249 ); 249 );
250 modalInstance.result.then( 250 modalInstance.result.then(
251 function(notaPedido) { 251 function(notaPedido) {
252 //añado cabeceras 252 //añado cabeceras
253 $scope.notaPedido.id = notaPedido.id; 253 $scope.notaPedido.id = notaPedido.id;
254 removeCabecera('Moneda:'); 254 removeCabecera('Moneda:');
255 removeCabecera('Fecha cotizacion:'); 255 removeCabecera('Fecha cotizacion:');
256 removeCabecera('Cotizacion:'); 256 removeCabecera('Cotizacion:');
257 var cabeceras = [ 257 var cabeceras = [
258 { 258 {
259 label: 'Moneda', 259 label: 'Moneda:',
260 valor: notaPedido.cotizacion[0].moneda[0].DETALLE 260 valor: notaPedido.cotizacion[0].moneda[0].DETALLE
261 }, 261 },
262 { 262 {
263 label: 'Fecha cotizacion', 263 label: 'Fecha cotizacion:',
264 valor: $filter('date')(notaPedido.cotizacion[0].FECHA, 264 valor: $filter('date')(notaPedido.cotizacion[0].FECHA,
265 'dd/MM/yyyy') 265 'dd/MM/yyyy')
266 }, 266 },
267 { 267 {
268 label: 'Cotizacion', 268 label: 'Cotizacion:',
269 valor: notaPedido.cotizacion[0].VENDEDOR 269 valor: notaPedido.cotizacion[0].VENDEDOR
270 }, 270 },
271 { 271 {
272 label: 'Cliente:', 272 label: 'Cliente:',
273 valor: notaPedido.cliente[0].NOM 273 valor: notaPedido.cliente[0].NOM
274 }, 274 },
275 { 275 {
276 label: 'Domicilio:', 276 label: 'Domicilio:',
277 valor: notaPedido.domicilioStamp 277 valor: notaPedido.domicilioStamp
278 }, 278 },
279 { 279 {
280 label: 'Vendedor:', 280 label: 'Vendedor:',
281 valor: notaPedido.vendedor[0].NomVen 281 valor: notaPedido.vendedor[0].NomVen
282 }, 282 },
283 { 283 {
284 label: 'Proveedor:', 284 label: 'Proveedor:',
285 valor: notaPedido.proveedor[0].NOM 285 valor: notaPedido.proveedor[0].NOM
286 }, 286 },
287 { 287 {
288 label: 'Flete:', 288 label: 'Flete:',
289 valor: notaPedido.flete === 1 ? 'Si' : 'No' 289 valor: notaPedido.flete === 1 ? 'Si' : 'No'
290 }, 290 },
291 { 291 {
292 label: 'FOB:', 292 label: 'FOB:',
293 valor: notaPedido.fob === 1 ? 'Si' : 'No' 293 valor: notaPedido.fob === 1 ? 'Si' : 'No'
294 }, 294 },
295 { 295 {
296 label: 'Precio condicion:', 296 label: 'Precio condicion:',
297 valor: valorPrecioCondicion() 297 valor: valorPrecioCondicion()
298 } 298 }
299 ]; 299 ];
300 //TODO MOSTRAR PLAZOS 300 //TODO MOSTRAR PLAZOS
301 function valorPrecioCondicion() { 301 function valorPrecioCondicion() {
302 if(notaPedido.idPrecioCondicion > 0) { 302 if(notaPedido.idPrecioCondicion > 0) {
303 return notaPedido.precioCondicion[0].nombre; 303 return notaPedido.precioCondicion[0].nombre;
304 } else { 304 } else {
305 return 'Ingreso Manual'; 305 return 'Ingreso Manual';
306 } 306 }
307 } 307 }
308 308
309 if(notaPedido.flete === 1) { 309 if(notaPedido.flete === 1) {
310 var cabeceraBomba = { 310 var cabeceraBomba = {
311 label: 'Bomba', 311 label: 'Bomba',
312 valor: notaPedido.bomba === 1 ? 'Si' : 'No' 312 valor: notaPedido.bomba === 1 ? 'Si' : 'No'
313 }; 313 };
314 if(notaPedido.kilometros) { 314 if(notaPedido.kilometros) {
315 var cabeceraKilometros = { 315 var cabeceraKilometros = {
316 label: 'Kilometros', 316 label: 'Kilometros',
317 valor: notaPedido.kilometros 317 valor: notaPedido.kilometros
318 }; 318 };
319 cabeceras.push(cabeceraKilometros); 319 cabeceras.push(cabeceraKilometros);
320 } 320 }
321 cabeceras.push(cabeceraBomba); 321 cabeceras.push(cabeceraBomba);
322 } 322 }
323 $scope.articulosTabla = notaPedido.articulosNotaPedido; 323 $scope.articulosTabla = notaPedido.articulosNotaPedido;
324 notaPedidoBusinessService.calcularArticulos($scope.articulosTabla,
325 notaPedido.cotizacion[0].VENDEDOR);
324 if(notaPedido.precioCondicion.length > 0) { 326 if(notaPedido.precioCondicion.length > 0) {
325 $scope.idLista = notaPedido.precioCondicion[0].idListaPrecio; 327 $scope.idLista = notaPedido.precioCondicion[0].idListaPrecio;
326 } else { 328 } else {
327 $scope.idLista = -1; 329 $scope.idLista = -1;
328 } 330 }
329 $scope.comprobante = rellenar(notaPedido.numeroNotaPedido, 8); 331 $scope.comprobante = rellenar(notaPedido.numeroNotaPedido, 8);
330 $scope.notaPedido = notaPedido; 332 $scope.notaPedido = notaPedido;
331 $scope.notaPedido.vendedor = notaPedido.vendedor[0]; 333 $scope.notaPedido.vendedor = notaPedido.vendedor[0];
332 $scope.notaPedido.cliente = notaPedido.cliente[0]; 334 $scope.notaPedido.cliente = notaPedido.cliente[0];
333 $scope.notaPedido.proveedor = notaPedido.proveedor[0]; 335 $scope.notaPedido.proveedor = notaPedido.proveedor[0];
334 $scope.notaPedido.moneda = notaPedido.cotizacion[0].moneda[0]; 336 $scope.notaPedido.moneda = notaPedido.cotizacion[0].moneda[0];
335 $scope.notaPedido.cotizacion = notaPedido.cotizacion[0]; 337 $scope.notaPedido.cotizacion = notaPedido.cotizacion[0];
336 $scope.plazosPagos = notaPedido.plazoPago; 338 $scope.plazosPagos = notaPedido.plazoPago;
337 addArrayCabecera(cabeceras); 339 addArrayCabecera(cabeceras);
338 340
339 }, function() { 341 }, function() {
340 // funcion ejecutada cuando se cancela el modal 342 // funcion ejecutada cuando se cancela el modal
341 } 343 }
342 ); 344 );
343 }; 345 };
344 346
345 $scope.seleccionarArticulo = function() { 347 $scope.seleccionarArticulo = function() {
346 if ($scope.idLista === undefined) { 348 if ($scope.idLista === undefined) {
347 focaModalService.alert( 349 focaModalService.alert(
348 'Primero seleccione una lista de precio y condicion'); 350 'Primero seleccione una lista de precio y condicion');
349 return; 351 return;
350 } 352 }
351 var modalInstance = $uibModal.open( 353 var modalInstance = $uibModal.open(
352 { 354 {
353 ariaLabelledBy: 'Busqueda de Productos', 355 ariaLabelledBy: 'Busqueda de Productos',
354 templateUrl: 'modal-busqueda-productos.html', 356 templateUrl: 'modal-busqueda-productos.html',
355 controller: 'modalBusquedaProductosCtrl', 357 controller: 'modalBusquedaProductosCtrl',
356 resolve: { 358 resolve: {
357 parametroProducto: { 359 parametroProducto: {
358 idLista: $scope.idLista, 360 idLista: $scope.idLista,
359 cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, 361 cotizacion: $scope.notaPedido.cotizacion.VENDEDOR,
360 simbolo: $scope.notaPedido.moneda.SIMBOLO 362 simbolo: $scope.notaPedido.moneda.SIMBOLO
361 } 363 }
362 }, 364 },
363 size: 'lg' 365 size: 'lg'
364 } 366 }
365 ); 367 );
366 modalInstance.result.then( 368 modalInstance.result.then(
367 function(producto) { 369 function(producto) {
368 var newArt = 370 var newArt =
369 { 371 {
370 id: 0, 372 id: 0,
371 codigo: producto.codigo, 373 codigo: producto.codigo,
372 sector: producto.sector, 374 sector: producto.sector,
373 sectorCodigo: producto.sector + '-' + producto.codigo, 375 sectorCodigo: producto.sector + '-' + producto.codigo,
374 descripcion: producto.descripcion, 376 descripcion: producto.descripcion,
375 item: $scope.articulosTabla.length + 1, 377 item: $scope.articulosTabla.length + 1,
376 nombre: producto.descripcion, 378 nombre: producto.descripcion,
377 precio: parseFloat(producto.precio.toFixed(4)), 379 precio: parseFloat(producto.precio.toFixed(4)),
378 costoUnitario: producto.costo, 380 costoUnitario: producto.costo,
379 editCantidad: false, 381 editCantidad: false,
380 editPrecio: false, 382 editPrecio: false,
381 rubro: producto.CodRub, 383 rubro: producto.CodRub,
382 exentoUnitario: producto.precio, 384 exentoUnitario: producto.precio,
383 ivaUnitario: producto.IMPIVA, 385 ivaUnitario: producto.IMPIVA,
384 impuestoInternoUnitario: producto.ImpInt, 386 impuestoInternoUnitario: producto.ImpInt,
385 impuestoInterno1Unitario: producto.ImpInt2, 387 impuestoInterno1Unitario: producto.ImpInt2,
386 impuestoInterno2Unitario: producto.ImpInt3, 388 impuestoInterno2Unitario: producto.ImpInt3,
387 precioLista: producto.precio, 389 precioLista: producto.precio,
388 combustible: 1, 390 combustible: 1,
389 facturado: 0 391 facturado: 0
390 }; 392 };
391 $scope.articuloACargar = newArt; 393 $scope.articuloACargar = newArt;
392 $scope.cargando = false; 394 $scope.cargando = false;
393 }, function() { 395 }, function() {
394 // funcion ejecutada cuando se cancela el modal 396 // funcion ejecutada cuando se cancela el modal
395 } 397 }
396 ); 398 );
397 }; 399 };
398 400
399 $scope.seleccionarVendedor = function() { 401 $scope.seleccionarVendedor = function() {
400 var modalInstance = $uibModal.open( 402 var modalInstance = $uibModal.open(
401 { 403 {
402 ariaLabelledBy: 'Busqueda de Vendedores', 404 ariaLabelledBy: 'Busqueda de Vendedores',
403 templateUrl: 'modal-vendedores.html', 405 templateUrl: 'modal-vendedores.html',
404 controller: 'modalVendedoresCtrl', 406 controller: 'modalVendedoresCtrl',
405 size: 'lg' 407 size: 'lg'
406 } 408 }
407 ); 409 );
408 modalInstance.result.then( 410 modalInstance.result.then(
409 function(vendedor) { 411 function(vendedor) {
410 addCabecera('Vendedor:', vendedor.NomVen); 412 addCabecera('Vendedor:', vendedor.NomVen);
411 $scope.notaPedido.vendedor = vendedor; 413 $scope.notaPedido.vendedor = vendedor;
412 }, function() { 414 }, function() {
413 415
414 } 416 }
415 ); 417 );
416 }; 418 };
417 419
418 $scope.seleccionarProveedor = function() { 420 $scope.seleccionarProveedor = function() {
419 var modalInstance = $uibModal.open( 421 var modalInstance = $uibModal.open(
420 { 422 {
421 ariaLabelledBy: 'Busqueda de Proveedor', 423 ariaLabelledBy: 'Busqueda de Proveedor',
422 templateUrl: 'modal-proveedor.html', 424 templateUrl: 'modal-proveedor.html',
423 controller: 'focaModalProveedorCtrl', 425 controller: 'focaModalProveedorCtrl',
424 size: 'lg', 426 size: 'lg',
425 resolve: { 427 resolve: {
426 transportista: function() { 428 transportista: function() {
427 return false; 429 return false;
428 } 430 }
429 } 431 }
430 } 432 }
431 ); 433 );
432 modalInstance.result.then( 434 modalInstance.result.then(
433 function(proveedor) { 435 function(proveedor) {
434 $scope.notaPedido.proveedor = proveedor; 436 $scope.notaPedido.proveedor = proveedor;
435 addCabecera('Proveedor:', proveedor.NOM); 437 addCabecera('Proveedor:', proveedor.NOM);
436 }, function() { 438 }, function() {
437 439
438 } 440 }
439 ); 441 );
440 }; 442 };
441 443
442 $scope.seleccionarCliente = function() { 444 $scope.seleccionarCliente = function() {
443 445
444 var modalInstance = $uibModal.open( 446 var modalInstance = $uibModal.open(
445 { 447 {
446 ariaLabelledBy: 'Busqueda de Cliente', 448 ariaLabelledBy: 'Busqueda de Cliente',
447 templateUrl: 'foca-busqueda-cliente-modal.html', 449 templateUrl: 'foca-busqueda-cliente-modal.html',
448 controller: 'focaBusquedaClienteModalController', 450 controller: 'focaBusquedaClienteModalController',
449 size: 'lg' 451 size: 'lg'
450 } 452 }
451 ); 453 );
452 modalInstance.result.then( 454 modalInstance.result.then(
453 function(cliente) { 455 function(cliente) {
454 $scope.abrirModalDomicilios(cliente); 456 $scope.abrirModalDomicilios(cliente);
455 }, function() { 457 }, function() {
456 458
457 } 459 }
458 ); 460 );
459 }; 461 };
460 462
461 $scope.abrirModalDomicilios = function(cliente) { 463 $scope.abrirModalDomicilios = function(cliente) {
462 var modalInstanceDomicilio = $uibModal.open( 464 var modalInstanceDomicilio = $uibModal.open(
463 { 465 {
464 ariaLabelledBy: 'Busqueda de Domicilios', 466 ariaLabelledBy: 'Busqueda de Domicilios',
465 templateUrl: 'modal-domicilio.html', 467 templateUrl: 'modal-domicilio.html',
466 controller: 'focaModalDomicilioController', 468 controller: 'focaModalDomicilioController',
467 resolve: { idCliente: function() { return cliente.cod; }}, 469 resolve: { idCliente: function() { return cliente.cod; }},
468 size: 'lg', 470 size: 'lg',
469 } 471 }
470 ); 472 );
471 modalInstanceDomicilio.result.then( 473 modalInstanceDomicilio.result.then(
472 function(domicilio) { 474 function(domicilio) {
473 $scope.notaPedido.domicilio = domicilio; 475 $scope.notaPedido.domicilio = domicilio;
474 $scope.notaPedido.cliente = { 476 $scope.notaPedido.cliente = {
475 COD: cliente.cod, 477 COD: cliente.cod,
476 CUIT: cliente.cuit, 478 CUIT: cliente.cuit,
477 NOM: cliente.nom 479 NOM: cliente.nom
478 }; 480 };
479 addCabecera('Cliente:', cliente.nom); 481 addCabecera('Cliente:', cliente.nom);
480 var domicilioStamp = 482 var domicilioStamp =
481 domicilio.Calle + ' ' + domicilio.Numero + ', ' + 483 domicilio.Calle + ' ' + domicilio.Numero + ', ' +
482 domicilio.Localidad + ', ' + domicilio.Provincia; 484 domicilio.Localidad + ', ' + domicilio.Provincia;
483 $scope.notaPedido.domicilioStamp = domicilioStamp; 485 $scope.notaPedido.domicilioStamp = domicilioStamp;
484 addCabecera('Domicilio:', domicilioStamp); 486 addCabecera('Domicilio:', domicilioStamp);
485 }, function() { 487 }, function() {
486 $scope.seleccionarCliente(); 488 $scope.seleccionarCliente();
487 return; 489 return;
488 } 490 }
489 ); 491 );
490 }; 492 };
491 493
492 $scope.mostrarFichaCliente = function() { 494 $scope.mostrarFichaCliente = function() {
493 $uibModal.open( 495 $uibModal.open(
494 { 496 {
495 ariaLabelledBy: 'Datos del Cliente', 497 ariaLabelledBy: 'Datos del Cliente',
496 templateUrl: 'foca-crear-nota-pedido-ficha-cliente.html', 498 templateUrl: 'foca-crear-nota-pedido-ficha-cliente.html',
497 controller: 'focaCrearNotaPedidoFichaClienteController', 499 controller: 'focaCrearNotaPedidoFichaClienteController',
498 size: 'lg' 500 size: 'lg'
499 } 501 }
500 ); 502 );
501 }; 503 };
502 504
503 $scope.getTotal = function() { 505 $scope.getTotal = function() {
504 var total = 0; 506 var total = 0;
505 var arrayTempArticulos = $scope.articulosTabla; 507 var arrayTempArticulos = $scope.articulosTabla;
506 for (var i = 0; i < arrayTempArticulos.length; i++) { 508 for (var i = 0; i < arrayTempArticulos.length; i++) {
507 total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; 509 total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad;
508 } 510 }
509 return parseFloat(total.toFixed(2)); 511 return parseFloat(total.toFixed(2));
510 }; 512 };
511 513
512 $scope.getSubTotal = function() { 514 $scope.getSubTotal = function() {
513 if($scope.articuloACargar) { 515 if($scope.articuloACargar) {
514 return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; 516 return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad;
515 } 517 }
516 }; 518 };
517 519
518 $scope.abrirModalListaPrecio = function() { 520 $scope.abrirModalListaPrecio = function() {
519 var modalInstance = $uibModal.open( 521 var modalInstance = $uibModal.open(
520 { 522 {
521 ariaLabelledBy: 'Busqueda de Precio Condición', 523 ariaLabelledBy: 'Busqueda de Precio Condición',
522 templateUrl: 'modal-precio-condicion.html', 524 templateUrl: 'modal-precio-condicion.html',
523 controller: 'focaModalPrecioCondicionController', 525 controller: 'focaModalPrecioCondicionController',
524 size: 'lg' 526 size: 'lg'
525 } 527 }
526 ); 528 );
527 modalInstance.result.then( 529 modalInstance.result.then(
528 function(precioCondicion) { 530 function(precioCondicion) {
529 var cabecera = ''; 531 var cabecera = '';
530 var plazosConcat = ''; 532 var plazosConcat = '';
531 if(!Array.isArray(precioCondicion)) { 533 if(!Array.isArray(precioCondicion)) {
532 $scope.notaPedido.idPrecioCondicion = precioCondicion.id; 534 $scope.notaPedido.idPrecioCondicion = precioCondicion.id;
533 $scope.plazosPagos = precioCondicion.plazoPago; 535 $scope.plazosPagos = precioCondicion.plazoPago;
534 $scope.idLista = precioCondicion.idListaPrecio; 536 $scope.idLista = precioCondicion.idListaPrecio;
535 for(var i = 0; i < precioCondicion.plazoPago.length; i++) { 537 for(var i = 0; i < precioCondicion.plazoPago.length; i++) {
536 plazosConcat += precioCondicion.plazoPago[i].dias + ' '; 538 plazosConcat += precioCondicion.plazoPago[i].dias + ' ';
537 } 539 }
538 cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); 540 cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim();
539 } else { //Cuando se ingresan los plazos manualmente 541 } else { //Cuando se ingresan los plazos manualmente
540 $scope.notaPedido.idPrecioCondicion = 0; 542 $scope.notaPedido.idPrecioCondicion = 0;
541 $scope.idLista = -1; //-1, el modal productos busca todos los productos 543 $scope.idLista = -1; //-1, el modal productos busca todos los productos
542 $scope.plazosPagos = precioCondicion; 544 $scope.plazosPagos = precioCondicion;
543 for(var j = 0; j < precioCondicion.length; j++) { 545 for(var j = 0; j < precioCondicion.length; j++) {
544 plazosConcat += precioCondicion[j].dias + ' '; 546 plazosConcat += precioCondicion[j].dias + ' ';
545 } 547 }
546 cabecera = 'Ingreso manual ' + plazosConcat.trim(); 548 cabecera = 'Ingreso manual ' + plazosConcat.trim();
547 } 549 }
548 $scope.articulosTabla = []; 550 $scope.articulosTabla = [];
549 addCabecera('Precios y condiciones:', cabecera); 551 addCabecera('Precios y condiciones:', cabecera);
550 }, function() { 552 }, function() {
551 553
552 } 554 }
553 ); 555 );
554 }; 556 };
555 557
556 $scope.abrirModalFlete = function() { 558 $scope.abrirModalFlete = function() {
557 var modalInstance = $uibModal.open( 559 var modalInstance = $uibModal.open(
558 { 560 {
559 ariaLabelledBy: 'Busqueda de Flete', 561 ariaLabelledBy: 'Busqueda de Flete',
560 templateUrl: 'modal-flete.html', 562 templateUrl: 'modal-flete.html',
561 controller: 'focaModalFleteController', 563 controller: 'focaModalFleteController',
562 size: 'lg', 564 size: 'lg',
563 resolve: { 565 resolve: {
564 parametrosFlete: 566 parametrosFlete:
565 function() { 567 function() {
566 return { 568 return {
567 flete: $scope.notaPedido.flete ? '1' : 569 flete: $scope.notaPedido.flete ? '1' :
568 ($scope.notaPedido.fob ? 'FOB' : 570 ($scope.notaPedido.fob ? 'FOB' :
569 ($scope.notaPedido.flete === undefined ? null : '0')), 571 ($scope.notaPedido.flete === undefined ? null : '0')),
570 bomba: $scope.notaPedido.bomba ? '1' : 572 bomba: $scope.notaPedido.bomba ? '1' :
571 ($scope.notaPedido.bomba === undefined ? null : '0'), 573 ($scope.notaPedido.bomba === undefined ? null : '0'),
572 kilometros: $scope.notaPedido.kilometros 574 kilometros: $scope.notaPedido.kilometros
573 }; 575 };
574 } 576 }
575 } 577 }
576 } 578 }
577 ); 579 );
578 modalInstance.result.then( 580 modalInstance.result.then(
579 function(datos) { 581 function(datos) {
580 $scope.notaPedido.flete = datos.flete; 582 $scope.notaPedido.flete = datos.flete;
581 $scope.notaPedido.fob = datos.FOB; 583 $scope.notaPedido.fob = datos.FOB;
582 $scope.notaPedido.bomba = datos.bomba; 584 $scope.notaPedido.bomba = datos.bomba;
583 $scope.notaPedido.kilometros = datos.kilometros; 585 $scope.notaPedido.kilometros = datos.kilometros;
584 586
585 addCabecera('Flete:', datos.flete ? 'Si' : 587 addCabecera('Flete:', datos.flete ? 'Si' :
586 ($scope.notaPedido.fob ? 'FOB' : 'No')); 588 ($scope.notaPedido.fob ? 'FOB' : 'No'));
587 if(datos.flete) { 589 if(datos.flete) {
588 addCabecera('Bomba:', datos.bomba ? 'Si' : 'No'); 590 addCabecera('Bomba:', datos.bomba ? 'Si' : 'No');
589 addCabecera('Kilometros:', datos.kilometros); 591 addCabecera('Kilometros:', datos.kilometros);
590 } else { 592 } else {
591 removeCabecera('Bomba:'); 593 removeCabecera('Bomba:');
592 removeCabecera('Kilometros:'); 594 removeCabecera('Kilometros:');
593 $scope.notaPedido.fob = false; 595 $scope.notaPedido.fob = false;
594 $scope.notaPedido.bomba = false; 596 $scope.notaPedido.bomba = false;
595 $scope.notaPedido.kilometros = null; 597 $scope.notaPedido.kilometros = null;
596 } 598 }
597 }, function() { 599 }, function() {
598 600
599 } 601 }
600 ); 602 );
601 }; 603 };
602 604
603 $scope.abrirModalMoneda = function() { 605 $scope.abrirModalMoneda = function() {
604 var modalInstance = $uibModal.open( 606 var modalInstance = $uibModal.open(
605 { 607 {
606 ariaLabelledBy: 'Busqueda de Moneda', 608 ariaLabelledBy: 'Busqueda de Moneda',
607 templateUrl: 'modal-moneda.html', 609 templateUrl: 'modal-moneda.html',
608 controller: 'focaModalMonedaController', 610 controller: 'focaModalMonedaController',
609 size: 'lg' 611 size: 'lg'
610 } 612 }
611 ); 613 );
612 modalInstance.result.then( 614 modalInstance.result.then(
613 function(moneda) { 615 function(moneda) {
614 $scope.abrirModalCotizacion(moneda); 616 $scope.abrirModalCotizacion(moneda);
615 }, function() { 617 }, function() {
616 618
617 } 619 }
618 ); 620 );
619 }; 621 };
620 622
621 $scope.abrirModalCotizacion = function(moneda) { 623 $scope.abrirModalCotizacion = function(moneda) {
622 var modalInstance = $uibModal.open( 624 var modalInstance = $uibModal.open(
623 { 625 {
624 ariaLabelledBy: 'Busqueda de Cotización', 626 ariaLabelledBy: 'Busqueda de Cotización',
625 templateUrl: 'modal-cotizacion.html', 627 templateUrl: 'modal-cotizacion.html',
626 controller: 'focaModalCotizacionController', 628 controller: 'focaModalCotizacionController',
627 size: 'lg', 629 size: 'lg',
628 resolve: {idMoneda: function() {return moneda.ID;}} 630 resolve: {idMoneda: function() {return moneda.ID;}}
629 } 631 }
630 ); 632 );
631 modalInstance.result.then( 633 modalInstance.result.then(
632 function(cotizacion) { 634 function(cotizacion) {
633 var articulosTablaTemp = $scope.articulosTabla; 635 var articulosTablaTemp = $scope.articulosTabla;
634 for(var i = 0; i < articulosTablaTemp.length; i++) { 636 for(var i = 0; i < articulosTablaTemp.length; i++) {
635 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * 637 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio *
636 $scope.notaPedido.cotizacion.VENDEDOR; 638 $scope.notaPedido.cotizacion.VENDEDOR;
637 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / 639 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio /
638 cotizacion.VENDEDOR; 640 cotizacion.VENDEDOR;
639 } 641 }
640 $scope.articulosTabla = articulosTablaTemp; 642 $scope.articulosTabla = articulosTablaTemp;
641 $scope.notaPedido.moneda = moneda; 643 $scope.notaPedido.moneda = moneda;
642 $scope.notaPedido.cotizacion = cotizacion; 644 $scope.notaPedido.cotizacion = cotizacion;
643 addCabecera('Moneda:', moneda.DETALLE); 645 addCabecera('Moneda:', moneda.DETALLE);
644 addCabecera( 646 addCabecera(
645 'Fecha cotizacion:', 647 'Fecha cotizacion:',
646 $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') 648 $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy')
647 ); 649 );
648 addCabecera('Cotizacion:', cotizacion.VENDEDOR); 650 addCabecera('Cotizacion:', cotizacion.VENDEDOR);
649 }, function() { 651 }, function() {
650 652
651 } 653 }
652 ); 654 );
653 }; 655 };
654 656
655 $scope.agregarATabla = function(key) { 657 $scope.agregarATabla = function(key) {
656 if(key === 13) { 658 if(key === 13) {
657 if($scope.articuloACargar.cantidad === undefined || 659 if($scope.articuloACargar.cantidad === undefined ||
658 $scope.articuloACargar.cantidad === 0 || 660 $scope.articuloACargar.cantidad === 0 ||
659 $scope.articuloACargar.cantidad === null ) { 661 $scope.articuloACargar.cantidad === null ) {
660 focaModalService.alert('El valor debe ser al menos 1'); 662 focaModalService.alert('El valor debe ser al menos 1');
661 return; 663 return;
662 } 664 }
663 delete $scope.articuloACargar.sectorCodigo; 665 delete $scope.articuloACargar.sectorCodigo;
664 $scope.articulosTabla.push($scope.articuloACargar); 666 $scope.articulosTabla.push($scope.articuloACargar);
665 $scope.cargando = true; 667 $scope.cargando = true;
666 } 668 }
667 }; 669 };
668 670
669 $scope.quitarArticulo = function(key) { 671 $scope.quitarArticulo = function(key) {
670 $scope.articulosTabla.splice(key, 1); 672 $scope.articulosTabla.splice(key, 1);
671 }; 673 };
672 674
673 $scope.editarArticulo = function(key, articulo) { 675 $scope.editarArticulo = function(key, articulo) {
674 if(key === 13) { 676 if(key === 13) {
675 if(articulo.cantidad === null || articulo.cantidad === 0 || 677 if(articulo.cantidad === null || articulo.cantidad === 0 ||
676 articulo.cantidad === undefined) { 678 articulo.cantidad === undefined) {
677 focaModalService.alert('El valor debe ser al menos 1'); 679 focaModalService.alert('El valor debe ser al menos 1');
678 return; 680 return;
679 } 681 }
680 articulo.editCantidad = false; 682 articulo.editCantidad = false;
681 articulo.editPrecio = false; 683 articulo.editPrecio = false;
682 } 684 }
683 }; 685 };
684 686
685 $scope.cambioEdit = function(articulo, propiedad) { 687 $scope.cambioEdit = function(articulo, propiedad) {
686 if(propiedad === 'cantidad') { 688 if(propiedad === 'cantidad') {
687 articulo.editCantidad = true; 689 articulo.editCantidad = true;
688 } else if(propiedad === 'precio') { 690 } else if(propiedad === 'precio') {
689 articulo.editPrecio = true; 691 articulo.editPrecio = true;
690 } 692 }
691 }; 693 };
692 694
693 $scope.limpiarFlete = function() { 695 $scope.limpiarFlete = function() {
694 $scope.notaPedido.fleteNombre = ''; 696 $scope.notaPedido.fleteNombre = '';
695 $scope.notaPedido.chofer = ''; 697 $scope.notaPedido.chofer = '';
696 $scope.notaPedido.vehiculo = ''; 698 $scope.notaPedido.vehiculo = '';
697 $scope.notaPedido.kilometros = ''; 699 $scope.notaPedido.kilometros = '';
698 $scope.notaPedido.costoUnitarioKmFlete = ''; 700 $scope.notaPedido.costoUnitarioKmFlete = '';
699 $scope.choferes = ''; 701 $scope.choferes = '';
700 $scope.vehiculos = ''; 702 $scope.vehiculos = '';
701 }; 703 };
702 704
703 $scope.limpiarPantalla = function() { 705 $scope.limpiarPantalla = function() {
704 $scope.limpiarFlete(); 706 $scope.limpiarFlete();
705 $scope.notaPedido.flete = '0'; 707 $scope.notaPedido.flete = '0';
706 $scope.notaPedido.bomba = '0'; 708 $scope.notaPedido.bomba = '0';
707 $scope.notaPedido.precioCondicion = ''; 709 $scope.notaPedido.precioCondicion = '';
708 $scope.articulosTabla = []; 710 $scope.articulosTabla = [];
709 $scope.notaPedido.vendedor.nombre = ''; 711 $scope.notaPedido.vendedor.nombre = '';
710 $scope.notaPedido.cliente = {nombre: ''}; 712 $scope.notaPedido.cliente = {nombre: ''};
711 $scope.notaPedido.domicilio = {dom: ''}; 713 $scope.notaPedido.domicilio = {dom: ''};
712 $scope.domiciliosCliente = []; 714 $scope.domiciliosCliente = [];
713 }; 715 };
714 716
715 $scope.resetFilter = function() { 717 $scope.resetFilter = function() {
716 $scope.articuloACargar = {}; 718 $scope.articuloACargar = {};
717 $scope.cargando = true; 719 $scope.cargando = true;
718 }; 720 };
719 //Recibe aviso si el teclado está en uso 721 //Recibe aviso si el teclado está en uso
720 $rootScope.$on('usarTeclado', function(event, data) { 722 $rootScope.$on('usarTeclado', function(event, data) {
721 if(data) { 723 if(data) {
722 $scope.mostrarTeclado = true; 724 $scope.mostrarTeclado = true;
723 return; 725 return;
724 } 726 }
725 $scope.mostrarTeclado = false; 727 $scope.mostrarTeclado = false;
726 }); 728 });
727 729
728 $scope.selectFocus = function($event) { 730 $scope.selectFocus = function($event) {
729 // Si el teclado esta en uso no selecciona el valor 731 // Si el teclado esta en uso no selecciona el valor
730 if($scope.mostrarTeclado) { 732 if($scope.mostrarTeclado) {
731 return; 733 return;
732 } 734 }
733 $event.target.select(); 735 $event.target.select();
734 }; 736 };
735 737
736 $scope.salir = function() { 738 $scope.salir = function() {
737 $location.path('/'); 739 $location.path('/');
738 }; 740 };
739 741
740 $scope.parsearATexto = function(articulo) { 742 $scope.parsearATexto = function(articulo) {
741 articulo.cantidad = parseFloat(articulo.cantidad); 743 articulo.cantidad = parseFloat(articulo.cantidad);
742 articulo.precio = parseFloat(articulo.precio); 744 articulo.precio = parseFloat(articulo.precio);
743 }; 745 };
744 746
745 function addArrayCabecera(array) { 747 function addArrayCabecera(array) {
746 for(var i = 0; i < array.length; i++) { 748 for(var i = 0; i < array.length; i++) {
747 addCabecera(array[i].label, array[i].valor); 749 addCabecera(array[i].label, array[i].valor);
748 } 750 }
749 } 751 }
750 752
751 function addCabecera(label, valor) { 753 function addCabecera(label, valor) {
752 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); 754 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true);
753 if(propiedad.length === 1) { 755 if(propiedad.length === 1) {
754 propiedad[0].valor = valor; 756 propiedad[0].valor = valor;
755 } else { 757 } else {
756 $scope.cabecera.push({label: label, valor: valor}); 758 $scope.cabecera.push({label: label, valor: valor});
757 } 759 }
758 } 760 }
759 761
760 function removeCabecera(label) { 762 function removeCabecera(label) {
761 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); 763 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true);
762 if(propiedad.length === 1) { 764 if(propiedad.length === 1) {
763 $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); 765 $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1);
764 } 766 }
765 } 767 }
766 768
767 function rellenar(relleno, longitud) { 769 function rellenar(relleno, longitud) {
768 relleno = '' + relleno; 770 relleno = '' + relleno;
769 while (relleno.length < longitud) { 771 while (relleno.length < longitud) {
770 relleno = '0' + relleno; 772 relleno = '0' + relleno;
771 } 773 }
772 774
773 return relleno; 775 return relleno;
774 } 776 }
775 777
776 function validarNotaRemitada(funcion) { 778 function validarNotaRemitada(funcion) {
777 if($scope.notaPedido.idRemito) { 779 if($scope.notaPedido.idRemito) {
778 focaModalService.alert('No se puede editar una nota de pedido remitada'); 780 focaModalService.alert('No se puede editar una nota de pedido remitada');
779 } 781 }
780 else { 782 else {
781 funcion(); 783 funcion();
782 } 784 }
783 } 785 }
784 } 786 }
785 ] 787 ]
786 ) 788 )
787 .controller('notaPedidoListaCtrl', [ 789 .controller('notaPedidoListaCtrl', [
788 '$scope', 790 '$scope',
789 'crearNotaPedidoService', 791 'crearNotaPedidoService',
790 '$location', 792 '$location',
791 function($scope, crearNotaPedidoService, $location) { 793 function($scope, crearNotaPedidoService, $location) {
792 crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { 794 crearNotaPedidoService.obtenerNotaPedido().then(function(datos) {
793 $scope.notaPedidos = datos.data; 795 $scope.notaPedidos = datos.data;
794 }); 796 });
795 $scope.editar = function(notaPedido) { 797 $scope.editar = function(notaPedido) {
796 crearNotaPedidoService.setNotaPedido(notaPedido); 798 crearNotaPedidoService.setNotaPedido(notaPedido);
797 $location.path('/venta-nota-pedido/abm/'); 799 $location.path('/venta-nota-pedido/abm/');
798 }; 800 };
799 $scope.crearPedido = function() { 801 $scope.crearPedido = function() {
800 crearNotaPedidoService.clearNotaPedido(); 802 crearNotaPedidoService.clearNotaPedido();
801 $location.path('/venta-nota-pedido/abm/'); 803 $location.path('/venta-nota-pedido/abm/');
802 }; 804 };
803 } 805 }
804 ]) 806 ])
805 .controller('focaCrearNotaPedidoFichaClienteController', [ 807 .controller('focaCrearNotaPedidoFichaClienteController', [
806 '$scope', 808 '$scope',
807 'crearNotaPedidoService', 809 'crearNotaPedidoService',
808 '$location', 810 '$location',
809 function($scope, crearNotaPedidoService, $location) { 811 function($scope, crearNotaPedidoService, $location) {
810 crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { 812 crearNotaPedidoService.obtenerNotaPedido().then(function(datos) {
811 $scope.notaPedidos = datos.data; 813 $scope.notaPedidos = datos.data;
812 }); 814 });
813 $scope.editar = function(notaPedido) { 815 $scope.editar = function(notaPedido) {
814 crearNotaPedidoService.setNotaPedido(notaPedido); 816 crearNotaPedidoService.setNotaPedido(notaPedido);
815 $location.path('/venta-nota-pedido/abm/'); 817 $location.path('/venta-nota-pedido/abm/');
816 }; 818 };
817 $scope.crearPedido = function() { 819 $scope.crearPedido = function() {
818 crearNotaPedidoService.clearNotaPedido(); 820 crearNotaPedidoService.clearNotaPedido();
819 $location.path('/venta-nota-pedido/abm/'); 821 $location.path('/venta-nota-pedido/abm/');
820 }; 822 };
821 } 823 }
822 ]); 824 ]);
823 825
src/views/nota-pedido.html
1 <div class="crear-nota-pedido"> 1 <div class="crear-nota-pedido">
2 <form name="formCrearNota" ng-submit="crearNotaPedido()" class="mb-0"> 2 <form name="formCrearNota" ng-submit="crearNotaPedido()" class="mb-0">
3 <div class="row"> 3 <div class="row">
4 <div class="col-md-10 offset-md-1 col-lg-8 offset-lg-2"> 4 <div class="col-md-10 offset-md-1 col-lg-8 offset-lg-2">
5 <div class="row p-1 panel-informativo"> 5 <div class="row p-1 panel-informativo">
6 <div class="col-12"> 6 <div class="col-12">
7 <div class="row"> 7 <div class="row">
8 <div class="col-12 col-sm-4 nota-pedido"> 8 <div class="col-12 col-sm-4 nota-pedido">
9 <h5>NOTA DE PEDIDO</h5> 9 <h5>NOTA DE PEDIDO</h5>
10 </div> 10 </div>
11 <div class="col-5 col-sm-4 numero-pedido" 11 <div class="col-5 col-sm-4 numero-pedido"
12 >Nº {{puntoVenta}}-{{comprobante}} 12 >Nº {{puntoVenta}}-{{comprobante}}
13 <button 13 <button
14 class="btn btn-xs btn-outline-dark" 14 class="btn btn-xs btn-outline-dark"
15 type="button" 15 type="button"
16 ng-click="seleccionarNotaPedido()" 16 ng-click="seleccionarNotaPedido()"
17 > 17 >
18 <i class="fa fa-search"></i> 18 <i class="fa fa-search"></i>
19 </button> 19 </button>
20 </div> 20 </div>
21 <div class="col-7 col-sm-4 text-right"> 21 <div class="col-7 col-sm-4 text-right">
22 Fecha: 22 Fecha:
23 <span 23 <span
24 ng-show="!datepickerAbierto" 24 ng-show="!datepickerAbierto"
25 ng-bind="now | date:'dd/MM/yyyy HH:mm'" 25 ng-bind="now | date:'dd/MM/yyyy HH:mm'"
26 ng-click="datepickerAbierto = true" 26 ng-click="datepickerAbierto = true"
27 > 27 >
28 </span> 28 </span>
29 <input 29 <input
30 ng-show="datepickerAbierto" 30 ng-show="datepickerAbierto"
31 type="date" 31 type="date"
32 ng-model="now" 32 ng-model="now"
33 ng-change="datepickerAbierto = false" 33 ng-change="datepickerAbierto = false"
34 ng-blur="datepickerAbierto = false" 34 ng-blur="datepickerAbierto = false"
35 class="form-control form-control-sm col-8 float-right" 35 class="form-control form-control-sm col-8 float-right"
36 foca-focus="datepickerAbierto" 36 foca-focus="datepickerAbierto"
37 hasta-hoy 37 hasta-hoy
38 /> 38 />
39 </div> 39 </div>
40 </div> 40 </div>
41 <div class="row"> 41 <div class="row">
42 <div class="col-auto" ng-repeat="cab in cabecera" ng-show="showCabecera"> 42 <div class="col-auto" ng-repeat="cab in cabecera" ng-show="showCabecera">
43 <span class="label" ng-bind="cab.label"></span> 43 <span class="label" ng-bind="cab.label"></span>
44 <span class="valor" ng-bind="cab.valor"></span> 44 <span class="valor" ng-bind="cab.valor"></span>
45 </div> 45 </div>
46 <a 46 <a
47 class="btn col-12 btn-secondary d-sm-none" 47 class="btn col-12 btn-secondary d-sm-none"
48 ng-show="cabecera.length > 0" 48 ng-show="cabecera.length > 0"
49 ng-click="showCabecera = !showCabecera" 49 ng-click="showCabecera = !showCabecera"
50 > 50 >
51 <i 51 <i
52 class="fa fa-chevron-down" 52 class="fa fa-chevron-down"
53 ng-hide="showCabecera" 53 ng-hide="showCabecera"
54 aria-hidden="true" 54 aria-hidden="true"
55 > 55 >
56 </i> 56 </i>
57 <i 57 <i
58 class="fa fa-chevron-up" 58 class="fa fa-chevron-up"
59 ng-show="showCabecera" 59 ng-show="showCabecera"
60 aria-hidden="true"> 60 aria-hidden="true">
61 </i> 61 </i>
62 </a> 62 </a>
63 </div> 63 </div>
64 </div> 64 </div>
65 </div> 65 </div>
66 <div class="row p-1 botonera-secundaria"> 66 <div class="row p-1 botonera-secundaria">
67 <div class="col-12"> 67 <div class="col-12">
68 <div class="row"> 68 <div class="row">
69 <div class="col-6 col-sm-3 px-0 py-0" ng-repeat="boton in botonera"> 69 <div class="col-6 col-sm-3 px-0 py-0" ng-repeat="boton in botonera">
70 <button 70 <button
71 type="button" 71 type="button"
72 class="btn btn-default btn-block btn-xs text-left py-2" 72 class="btn btn-default btn-block btn-xs text-left py-2"
73 ng-click="boton.accion()" 73 ng-click="boton.accion()"
74 ng-class="{'d-none d-sm-block': boton.texto == ''}" 74 ng-class="{'d-none d-sm-block': boton.texto == ''}"
75 > 75 >
76 <i 76 <i
77 class="fa fa-arrow-circle-right" 77 class="fa fa-arrow-circle-right"
78 ng-show="boton.texto != ''" 78 ng-show="boton.texto != ''"
79 ></i> 79 ></i>
80 &nbsp; 80 &nbsp;
81 {{boton.texto}} 81 {{boton.texto}}
82 </button> 82 </button>
83 </div> 83 </div>
84 </div> 84 </div>
85 </div> 85 </div>
86 </div> 86 </div>
87 </div> 87 </div>
88 </div> 88 </div>
89 </form> 89 </form>
90 <div class="row"> 90 <div class="row">
91 <div class="col-12 col-md-10 col-lg-8 offset-md-1 offset-lg-2"> 91 <div class="col-12 col-md-10 col-lg-8 offset-md-1 offset-lg-2">
92 <!-- PC --> 92 <!-- PC -->
93 <div class="row grilla-articulo align-items-end d-none d-sm-flex"> 93 <div class="row grilla-articulo align-items-end d-none d-sm-flex">
94 <table class="table tabla-articulo table-striped table-sm table-dark"> 94 <table class="table tabla-articulo table-striped table-sm table-dark">
95 <thead> 95 <thead>
96 <tr class="d-flex"> 96 <tr class="d-flex">
97 <th class="">#</th> 97 <th class="">#</th>
98 <th class="col">Código</th> 98 <th class="col">Código</th>
99 <th class="col-4">Descripción</th> 99 <th class="col-4">Descripción</th>
100 <th class="col text-right">Cantidad</th> 100 <th class="col text-right">Cantidad</th>
101 <th class="col text-right">Precio Unitario</th> 101 <th class="col text-right">Precio Unitario</th>
102 <th class="col text-right">SubTotal</th> 102 <th class="col text-right">SubTotal</th>
103 <th class="text-right"> 103 <th class="text-right">
104 <button 104 <button
105 class="btn btn-outline-secondary selectable" 105 class="btn btn-outline-secondary selectable"
106 ng-click="show = !show; masMenos()" 106 ng-click="show = !show; masMenos()"
107 > 107 >
108 <i 108 <i
109 class="fa fa-chevron-down" 109 class="fa fa-chevron-down"
110 ng-show="show" 110 ng-show="show"
111 aria-hidden="true" 111 aria-hidden="true"
112 > 112 >
113 </i> 113 </i>
114 <i 114 <i
115 class="fa fa-chevron-up" 115 class="fa fa-chevron-up"
116 ng-hide="show" 116 ng-hide="show"
117 aria-hidden="true"> 117 aria-hidden="true">
118 </i> 118 </i>
119 </button> 119 </button>
120 </th> 120 </th>
121 </tr> 121 </tr>
122 </thead> 122 </thead>
123 <tbody class="tabla-articulo-body"> 123 <tbody class="tabla-articulo-body">
124 <tr 124 <tr
125 ng-repeat="(key, articulo) in articulosTabla" 125 ng-repeat="(key, articulo) in articulosTabla"
126 ng-show="show || key == (articulosTabla.length - 1)" 126 ng-show="show || key == (articulosTabla.length - 1)"
127 class="d-flex" 127 class="d-flex"
128 > 128 >
129 <td ng-bind="key + 1"></td> 129 <td ng-bind="key + 1"></td>
130 <td 130 <td
131 class="col" 131 class="col"
132 ng-bind="articulo.sector + '-' + articulo.codigo" 132 ng-bind="articulo.sector + '-' + articulo.codigo"
133 ></td> 133 ></td>
134 <td 134 <td
135 class="col-4" 135 class="col-4"
136 ng-bind="articulo.descripcion" 136 ng-bind="articulo.descripcion"
137 ></td> 137 ></td>
138 <td class="col text-right"> 138 <td class="col text-right">
139 <input 139 <input
140 ng-show="articulo.editCantidad" 140 ng-show="articulo.editCantidad"
141 ng-model="articulo.cantidad" 141 ng-model="articulo.cantidad"
142 class="form-control" 142 class="form-control"
143 foca-tipo-input 143 foca-tipo-input
144 min="1" 144 min="1"
145 step="0.001" 145 step="0.001"
146 foca-focus="articulo.editCantidad" 146 foca-focus="articulo.editCantidad"
147 ng-keypress="editarArticulo($event.keyCode, articulo)" 147 ng-keypress="editarArticulo($event.keyCode, articulo)"
148 ng-focus="selectFocus($event)" 148 ng-focus="selectFocus($event)"
149 teclado-virtual 149 teclado-virtual
150 > 150 >
151 <i 151 <i
152 class="selectable" 152 class="selectable"
153 ng-click="cambioEdit(articulo, 'cantidad')" 153 ng-click="cambioEdit(articulo, 'cantidad')"
154 ng-hide="articulo.editCantidad" 154 ng-hide="articulo.editCantidad"
155 ng-bind="articulo.cantidad"> 155 ng-bind="articulo.cantidad">
156 </i> 156 </i>
157 </td> 157 </td>
158 <td class="col text-right"> 158 <td class="col text-right">
159 <input 159 <input
160 ng-show="articulo.editPrecio" 160 ng-show="articulo.editPrecio"
161 ng-model="articulo.precio" 161 ng-model="articulo.precio"
162 class="form-control" 162 class="form-control"
163 foca-tipo-input 163 foca-tipo-input
164 min="0" 164 min="0"
165 step="0.0001" 165 step="0.0001"
166 foca-focus="articulo.editPrecio" 166 foca-focus="articulo.editPrecio"
167 ng-keypress="editarArticulo($event.keyCode, articulo)" 167 ng-keypress="editarArticulo($event.keyCode, articulo)"
168 ng-focus="selectFocus($event)" 168 ng-focus="selectFocus($event)"
169 teclado-virtual 169 teclado-virtual
170 > 170 >
171 <i 171 <i
172 class="selectable" 172 class="selectable"
173 ng-click="idLista == -1 && cambioEdit(articulo, 'precio')" 173 ng-click="idLista == -1 && cambioEdit(articulo, 'precio')"
174 ng-hide="articulo.editPrecio" 174 ng-hide="articulo.editPrecio"
175 ng-bind="articulo.precio | 175 ng-bind="articulo.precio |
176 currency: notaPedido.moneda.SIMBOLO : 4"> 176 currency: notaPedido.moneda.SIMBOLO : 4">
177 </i> 177 </i>
178 </td> 178 </td>
179 <td 179 <td
180 class="col text-right" 180 class="col text-right"
181 ng-bind="(articulo.precio * articulo.cantidad) | 181 ng-bind="(articulo.precio * articulo.cantidad) |
182 currency: notaPedido.moneda.SIMBOLO"> 182 currency: notaPedido.moneda.SIMBOLO">
183 </td> 183 </td>
184 <td class="text-center"> 184 <td class="text-center">
185 <button 185 <button
186 ng-show="articulo.editCantidad || articulo.editPrecio" 186 ng-show="articulo.editCantidad || articulo.editPrecio"
187 class="btn btn-outline-secondary" 187 class="btn btn-outline-secondary"
188 ng-click="editarArticulo(13, articulo)" 188 ng-click="editarArticulo(13, articulo)"
189 > 189 >
190 <i class="fa fa-save"></i> 190 <i class="fa fa-save"></i>
191 </button> 191 </button>
192 <button 192 <button
193 class="btn btn-outline-secondary" 193 class="btn btn-outline-secondary"
194 ng-click="quitarArticulo(key)" 194 ng-click="quitarArticulo(key)"
195 > 195 >
196 <i class="fa fa-trash"></i> 196 <i class="fa fa-trash"></i>
197 </button> 197 </button>
198 </td> 198 </td>
199 </tr> 199 </tr>
200 </tbody> 200 </tbody>
201 <tfoot> 201 <tfoot>
202 <tr ng-show="!cargando" class="d-flex"> 202 <tr ng-show="!cargando" class="d-flex">
203 <td 203 <td
204 class="align-middle" 204 class="align-middle"
205 ng-bind="articulosTabla.length + 1" 205 ng-bind="articulosTabla.length + 1"
206 ></td> 206 ></td>
207 <td class="col"> 207 <td class="col">
208 <input 208 <input
209 class="form-control" 209 class="form-control"
210 ng-model="articuloACargar.sectorCodigo" 210 ng-model="articuloACargar.sectorCodigo"
211 readonly 211 readonly
212 > 212 >
213 </td> 213 </td>
214 <td class="col-4 tabla-articulo-descripcion"> 214 <td class="col-4 tabla-articulo-descripcion">
215 <input 215 <input
216 class="form-control" 216 class="form-control"
217 ng-model="articuloACargar.descripcion" 217 ng-model="articuloACargar.descripcion"
218 readonly 218 readonly
219 > 219 >
220 </td> 220 </td>
221 <td class="col text-right"> 221 <td class="col text-right">
222 <input 222 <input
223 class="form-control" 223 class="form-control"
224 foca-tipo-input 224 foca-tipo-input
225 min="1" 225 min="1"
226 step="0.001" 226 step="0.001"
227 ng-model="articuloACargar.cantidad" 227 ng-model="articuloACargar.cantidad"
228 foca-focus="!cargando" 228 foca-focus="!cargando"
229 esc-key="resetFilter()" 229 esc-key="resetFilter()"
230 ng-keypress="agregarATabla($event.keyCode)" 230 ng-keypress="agregarATabla($event.keyCode)"
231 teclado-virtual 231 teclado-virtual
232 > 232 >
233 </td> 233 </td>
234 <td class="col text-right"> 234 <td class="col text-right">
235 <input 235 <input
236 class="form-control" 236 class="form-control"
237 ng-value="articuloACargar.precio | 237 ng-value="articuloACargar.precio |
238 currency: notaPedido.moneda.SIMBOLO : 4" 238 currency: notaPedido.moneda.SIMBOLO : 4"
239 ng-show="idLista != -1" 239 ng-show="idLista != -1"
240 readonly 240 readonly
241 > 241 >
242 <input 242 <input
243 class="form-control" 243 class="form-control"
244 foca-tipo-input 244 foca-tipo-input
245 min="0" 245 min="0"
246 step="0.0001" 246 step="0.0001"
247 ng-model="articuloACargar.precio" 247 ng-model="articuloACargar.precio"
248 esc-key="resetFilter()" 248 esc-key="resetFilter()"
249 ng-keypress="agregarATabla($event.keyCode)" 249 ng-keypress="agregarATabla($event.keyCode)"
250 ng-show="idLista == -1" 250 ng-show="idLista == -1"
251 teclado-virtual 251 teclado-virtual
252 > 252 >
253 </td> 253 </td>
254 <td class="col text-right"> 254 <td class="col text-right">
255 <input 255 <input
256 class="form-control" 256 class="form-control"
257 ng-value="getSubTotal() | currency: notaPedido.moneda.SIMBOLO" 257 ng-value="getSubTotal() | currency: notaPedido.moneda.SIMBOLO"
258 readonly 258 readonly
259 ></td> 259 ></td>
260 <td class="text-center align-middle"> 260 <td class="text-center align-middle">
261 <button 261 <button
262 class="btn btn-outline-secondary" 262 class="btn btn-outline-secondary"
263 ng-click="agregarATabla(13)" 263 ng-click="agregarATabla(13)"
264 > 264 >
265 <i class="fa fa-save"></i> 265 <i class="fa fa-save"></i>
266 </button> 266 </button>
267 </td> 267 </td>
268 </tr> 268 </tr>
269 <tr ng-show="cargando" class="d-flex"> 269 <tr ng-show="cargando" class="d-flex">
270 <td colspan="7" class="col-12"> 270 <td colspan="7" class="col-12">
271 <input 271 <input
272 placeholder="Seleccione Articulo" 272 placeholder="Seleccione Articulo"
273 class="form-control form-control-sm" 273 class="form-control form-control-sm"
274 readonly 274 readonly
275 ng-click="seleccionarArticulo()" 275 ng-click="seleccionarArticulo()"
276 /> 276 />
277 </td> 277 </td>
278 </tr> 278 </tr>
279 <tr class="d-flex"> 279 <tr class="d-flex">
280 <td colspan="4" class="no-border-top"> 280 <td colspan="4" class="no-border-top">
281 <strong>Items:</strong> 281 <strong>Items:</strong>
282 <a ng-bind="articulosTabla.length"></a> 282 <a ng-bind="articulosTabla.length"></a>
283 </td> 283 </td>
284 <td class="text-right ml-auto table-celda-total no-border-top"> 284 <td class="text-right ml-auto table-celda-total no-border-top">
285 <h3>Total:</h3> 285 <h3>Total:</h3>
286 </td> 286 </td>
287 <td class="table-celda-total text-right no-border-top" colspan="1"> 287 <td class="table-celda-total text-right no-border-top" colspan="1">
288 <h3>{{getTotal() | currency: notaPedido.moneda.SIMBOLO}}</h3> 288 <h3>{{getTotal() | currency: notaPedido.moneda.SIMBOLO}}</h3>
289 </td> 289 </td>
290 <td class="text-right no-border-top"> 290 <td class="text-right no-border-top">
291 <button 291 <button
292 type="button" 292 type="button"
293 class="btn btn-default btn-sm" 293 class="btn btn-default btn-sm"
294 > 294 >
295 Totales 295 Totales
296 </button> 296 </button>
297 </td> 297 </td>
298 </tr> 298 </tr>
299 </tfoot> 299 </tfoot>
300 </table> 300 </table>
301 </div> 301 </div>
302 302
303 <!-- MOBILE --> 303 <!-- MOBILE -->
304 <div class="row d-sm-none"> 304 <div class="row d-sm-none">
305 <table class="table table-sm table-striped table-dark margin-bottom-mobile"> 305 <table class="table table-sm table-striped table-dark margin-bottom-mobile">
306 <thead> 306 <thead>
307 <tr class="d-flex"> 307 <tr class="d-flex">
308 <th class="">#</th> 308 <th class="">#</th>
309 <th class="col px-0"> 309 <th class="col px-0">
310 <div class="d-flex"> 310 <div class="d-flex">
311 <div class="col-4 px-1">Código</div> 311 <div class="col-4 px-1">Código</div>
312 <div class="col-8 px-1">Descripción</div> 312 <div class="col-8 px-1">Descripción</div>
313 </div> 313 </div>
314 <div class="d-flex"> 314 <div class="d-flex">
315 <div class="col-3 px-1">Cantidad</div> 315 <div class="col-3 px-1">Cantidad</div>
316 <div class="col px-1 text-right">P. Uni.</div> 316 <div class="col px-1 text-right">P. Uni.</div>
317 <div class="col px-1 text-right">Subtotal</div> 317 <div class="col px-1 text-right">Subtotal</div>
318 </div> 318 </div>
319 </th> 319 </th>
320 <th class="text-center tamaño-boton"> 320 <th class="text-center tamaño-boton">
321 &nbsp; 321 &nbsp;
322 </th> 322 </th>
323 </tr> 323 </tr>
324 </thead> 324 </thead>
325 <tbody> 325 <tbody>
326 <tr 326 <tr
327 ng-repeat="(key, articulo) in articulosTabla" 327 ng-repeat="(key, articulo) in articulosTabla"
328 ng-show="show || key == articulosTabla.length - 1" 328 ng-show="show || key == articulosTabla.length - 1"
329 > 329 >
330 <td class="w-100 align-middle d-flex p-0"> 330 <td class="w-100 align-middle d-flex p-0">
331 <div class="align-middle p-1"> 331 <div class="align-middle p-1">
332 <span ng-bind="key+1" class="align-middle"></span> 332 <span ng-bind="key+1" class="align-middle"></span>
333 </div> 333 </div>
334 <div class="col px-0"> 334 <div class="col px-0">
335 <div class="d-flex"> 335 <div class="d-flex">
336 <div class="col-4 px-1"> 336 <div class="col-4 px-1">
337 <span 337 <span
338 ng-bind="articulo.sector + '-' + articulo.codigo" 338 ng-bind="articulo.sector + '-' + articulo.codigo"
339 ></span> 339 ></span>
340 </div> 340 </div>
341 <div class="col-8 px-1"> 341 <div class="col-8 px-1">
342 <span ng-bind="articulo.descripcion"></span> 342 <span ng-bind="articulo.descripcion"></span>
343 </div> 343 </div>
344 </div> 344 </div>
345 <div class="d-flex"> 345 <div class="d-flex">
346 <div class="col-3 px-1"> 346 <div class="col-3 px-1">
347 <span ng-bind="'x' + articulo.cantidad"></span> 347 <span ng-bind="'x' + articulo.cantidad"></span>
348 </div> 348 </div>
349 <div class="col-3 px-1 text-right"> 349 <div class="col-3 px-1 text-right">
350 <span 350 <span
351 ng-bind="articulo.precio | 351 ng-bind="articulo.precio |
352 currency: notaPedido.moneda.SIMBOLO : 4" 352 currency: notaPedido.moneda.SIMBOLO : 4"
353 ></span> 353 ></span>
354 </div> 354 </div>
355 <div class="col px-1 text-right"> 355 <div class="col px-1 text-right">
356 <span 356 <span
357 ng-bind="(articulo.precio * articulo.cantidad) | 357 ng-bind="(articulo.precio * articulo.cantidad) |
358 currency: notaPedido.moneda.SIMBOLO" 358 currency: notaPedido.moneda.SIMBOLO"
359 > 359 >
360 </span> 360 </span>
361 </div> 361 </div>
362 </div> 362 </div>
363 </div> 363 </div>
364 <div class="align-middle p-1"> 364 <div class="align-middle p-1">
365 <button 365 <button
366 class="btn btn-outline-secondary" 366 class="btn btn-outline-secondary"
367 ng-click="quitarArticulo(key)" 367 ng-click="quitarArticulo(key)"
368 > 368 >
369 <i class="fa fa-trash"></i> 369 <i class="fa fa-trash"></i>
370 </button> 370 </button>
371 </div> 371 </div>
372 </td> 372 </td>
373 </tr> 373 </tr>
374 </tbody> 374 </tbody>
375 <tfoot> 375 <tfoot>
376 <!-- CARGANDO ITEM --> 376 <!-- CARGANDO ITEM -->
377 <tr ng-show="!cargando" class="d-flex"> 377 <tr ng-show="!cargando" class="d-flex">
378 <td 378 <td
379 class="align-middle p-1" 379 class="align-middle p-1"
380 ng-bind="articulosTabla.length + 1" 380 ng-bind="articulosTabla.length + 1"
381 ></td> 381 ></td>
382 <td class="col p-0"> 382 <td class="col p-0">
383 <div class="d-flex"> 383 <div class="d-flex">
384 <div class="col-4 px-1"> 384 <div class="col-4 px-1">
385 <span 385 <span
386 ng-bind="articuloACargar.sectorCodigo" 386 ng-bind="articuloACargar.sectorCodigo"
387 ></span> 387 ></span>
388 </div> 388 </div>
389 <div class="col-8 px-1"> 389 <div class="col-8 px-1">
390 <span ng-bind="articuloACargar.descripcion"></span> 390 <span ng-bind="articuloACargar.descripcion"></span>
391 </div> 391 </div>
392 </div> 392 </div>
393 <div class="d-flex"> 393 <div class="d-flex">
394 <div class="col-3 px-1 m-1"> 394 <div class="col-3 px-1 m-1">
395 <input 395 <input
396 class="form-control p-1" 396 class="form-control p-1"
397 foca-tipo-input 397 foca-tipo-input
398 min="1" 398 min="1"
399 ng-model="articuloACargar.cantidad" 399 ng-model="articuloACargar.cantidad"
400 foca-focus="!cargando" 400 foca-focus="!cargando"
401 ng-keypress="agregarATabla($event.keyCode)" 401 ng-keypress="agregarATabla($event.keyCode)"
402 style="height: auto; line-height: 1.1em" 402 style="height: auto; line-height: 1.1em"
403 > 403 >
404 </div> 404 </div>
405 <div class="col-3 px-1 text-right"> 405 <div class="col-3 px-1 text-right">
406 <span ng-bind="articuloACargar.precio | 406 <span ng-bind="articuloACargar.precio |
407 currency: notaPedido.moneda.SIMBOLO : 4"></span> 407 currency: notaPedido.moneda.SIMBOLO : 4"></span>
408 </div> 408 </div>
409 <div class="col px-1 text-right"> 409 <div class="col px-1 text-right">
410 <span 410 <span
411 ng-bind="getSubTotal() | 411 ng-bind="getSubTotal() |
412 currency: notaPedido.moneda.SIMBOLO" 412 currency: notaPedido.moneda.SIMBOLO"
413 > 413 >
414 </span> 414 </span>
415 </div> 415 </div>
416 </div> 416 </div>
417 </td> 417 </td>
418 <td class="text-center align-middle"> 418 <td class="text-center align-middle">
419 <button 419 <button
420 class="btn btn-outline-secondary" 420 class="btn btn-outline-secondary"
421 ng-click="agregarATabla(13)" 421 ng-click="agregarATabla(13)"
422 > 422 >
423 <i class="fa fa-save"></i> 423 <i class="fa fa-save"></i>
424 </button> 424 </button>
425 </td> 425 </td>
426 </tr> 426 </tr>
427 <!-- SELECCIONAR PRODUCTO --> 427 <!-- SELECCIONAR PRODUCTO -->
428 <tr ng-show="cargando" class="d-flex"> 428 <tr ng-show="cargando" class="d-flex">
429 <td class="col-12"> 429 <td class="col-12">
430 <input 430 <input
431 placeholder="Seleccione Articulo" 431 placeholder="Seleccione Articulo"
432 class="form-control form-control-sm" 432 class="form-control form-control-sm"
433 readonly 433 readonly
434 ng-click="seleccionarArticulo()" 434 ng-click="seleccionarArticulo()"
435 /> 435 />
436 </td> 436 </td>
437 </tr> 437 </tr>
438 <!-- TOOGLE EXPANDIR --> 438 <!-- TOOGLE EXPANDIR -->
439 <tr> 439 <tr>
440 <td class="col"> 440 <td class="col">
441 <button 441 <button
442 class="btn btn-outline-secondary selectable w-100" 442 class="btn btn-outline-secondary selectable w-100"
443 ng-click="show = !show; masMenos()" 443 ng-click="show = !show; masMenos()"
444 ng-show="articulosTabla.length > 0" 444 ng-show="articulosTabla.length > 0"
445 > 445 >
446 <i 446 <i
447 class="fa fa-chevron-down" 447 class="fa fa-chevron-down"
448 ng-hide="show" 448 ng-hide="show"
449 aria-hidden="true" 449 aria-hidden="true"
450 > 450 >
451 </i> 451 </i>
452 <i 452 <i
453 class="fa fa-chevron-up" 453 class="fa fa-chevron-up"
454 ng-show="show" 454 ng-show="show"
455 aria-hidden="true"> 455 aria-hidden="true">
456 </i> 456 </i>
457 </button> 457 </button>
458 </td> 458 </td>
459 </tr> 459 </tr>
460 <!-- FOOTER --> 460 <!-- FOOTER -->
461 <tr class="d-flex"> 461 <tr class="d-flex">
462 <td class="align-middle no-border-top" colspan="2"> 462 <td class="align-middle no-border-top" colspan="2">
463 <strong>Cantidad Items:</strong> 463 <strong>Cantidad Items:</strong>
464 <a ng-bind="articulosTabla.length"></a> 464 <a ng-bind="articulosTabla.length"></a>
465 </td> 465 </td>
466 <td class="text-right ml-auto table-celda-total no-border-top"> 466 <td class="text-right ml-auto table-celda-total no-border-top">
467 <h3>Total:</h3> 467 <h3>Total:</h3>
468 </td> 468 </td>
469 <td class="table-celda-total text-right no-border-top"> 469 <td class="table-celda-total text-right no-border-top">
470 <h3>{{getTotal() | currency: notaPedido.moneda.SIMBOLO}}</h3> 470 <h3>{{getTotal() | currency: notaPedido.moneda.SIMBOLO}}</h3>
471 </td> 471 </td>
472 </tr> 472 </tr>
473 </tfoot> 473 </tfoot>
474 </table> 474 </table>
475 </div> 475 </div>
476 </div> 476 </div>
477 <div class="col-auto my-2 col-lg-2 botonera-lateral d-none d-md-block"> 477 <div class="col-auto my-2 col-lg-2 botonera-lateral d-none d-md-block">
478 <div class="row align-items-end"> 478 <div class="row align-items-end">
479 <div class="col-12"> 479 <div class="col-12">
480 <button 480 <button
481 ng-click="crearNotaPedido()" 481 ng-click="crearNotaPedido()"
482 type="submit" 482 type="submit"
483 title="Crear nota pedido" 483 title="Crear nota pedido"
484 class="btn btn-default btn-block mb-2"> 484 class="btn btn-default btn-block mb-2"
485 ng-disabled="notaPedido.idRemito"
486 >
485 Guardar 487 Guardar
486 </button> 488 </button>
487 <button 489 <button
488 ng-click="salir()" 490 ng-click="salir()"
489 type="button" 491 type="button"
490 title="Salir" 492 title="Salir"
491 class="btn btn-default btn-block"> 493 class="btn btn-default btn-block">
492 Salir 494 Salir
493 </button> 495 </button>
494 </div> 496 </div>
495 </div> 497 </div>
496 </div> 498 </div>
497 </div> 499 </div>
498 <div class="row d-md-none fixed-bottom"> 500 <div class="row d-md-none fixed-bottom">
499 <div class="w-100 bg-dark d-flex px-3 acciones-mobile"> 501 <div class="w-100 bg-dark d-flex px-3 acciones-mobile">
500 <span class="ml-3 text-muted" ng-click="salir()">Salir</span> 502 <span class="ml-3 text-muted" ng-click="salir()">Salir</span>
501 <span class="mr-3 ml-auto" ng-click="crearNotaPedido()">Guardar</span> 503 <span class="mr-3 ml-auto" ng-click="crearNotaPedido()">Guardar</span>
502 </div> 504 </div>
503 </div> 505 </div>
504 </div> 506 </div>
505 507