Commit 7ea2b0fbbec5a15a3f89694c39be7cf42aec14cc

Authored by Eric Fernandez
1 parent 4f377f9fd6
Exists in master

cargar nota pedido para editar

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