Commit 47e6ce85d430614f50b2a241ef2750fb57b534f1

Authored by Nicolás Guarnieri
Exists in master

Merge remote-tracking branch 'upstream/master'

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