Commit 7f9a822e4970e02c8dfb4adfeebff78371a727b9

Authored by Pablo Marco del Pont
Exists in master

Merge branch 'master' into 'master'

cargar nota pedido para editar

See merge request modulos-npm/foca-crear-nota-pedido!84
src/js/controller.js
1 angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', 1 angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
2 [ 2 [
3 '$scope', '$uibModal', '$location', '$filter', 'crearNotaPedidoService', 3 '$scope', '$uibModal', '$location', '$filter', 'crearNotaPedidoService',
4 'focaModalService', 'notaPedidoBusinessService', '$rootScope', 'focaSeguimientoService', 4 'focaModalService', 'notaPedidoBusinessService', '$rootScope', 'focaSeguimientoService',
5 function( 5 function(
6 $scope, $uibModal, $location, $filter, crearNotaPedidoService, focaModalService, 6 $scope, $uibModal, $location, $filter, crearNotaPedidoService, focaModalService,
7 notaPedidoBusinessService, $rootScope, focaSeguimientoService 7 notaPedidoBusinessService, $rootScope, focaSeguimientoService
8 ) { 8 ) {
9 $scope.botonera = [ 9 $scope.botonera = [
10 {texto: 'Vendedor', accion: function() {$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 // Al guardar los datos de la nota de pedido logueamos la 183 // Al guardar los datos de la nota de pedido logueamos la
178 // actividad para su seguimiento. 184 // actividad para su seguimiento.
179 focaSeguimientoService.guardarPosicion( 185 focaSeguimientoService.guardarPosicion(
180 $scope.notaPedido.vendedor.codigo, 186 $scope.notaPedido.vendedor.codigo,
181 'Nota de pedido', 187 'Nota de pedido',
182 'Nº: ' + $filter('comprobante')([ 188 'Nº: ' + $filter('comprobante')([
183 $scope.puntoVenta, 189 $scope.puntoVenta,
184 $scope.comprobante 190 $scope.comprobante
185 ]) 191 ])
186 ); 192 );
187 notaPedidoBusinessService.addArticulos($scope.articulosTabla, 193 notaPedidoBusinessService.addArticulos($scope.articulosTabla,
188 data.data.id, $scope.notaPedido.cotizacion.VENDEDOR); 194 data.data.id, $scope.notaPedido.cotizacion.VENDEDOR);
189 var plazos = $scope.plazosPagos; 195 var plazos = $scope.plazosPagos;
190 196
191 for(var j = 0; j < plazos.length; j++) { 197 for(var j = 0; j < plazos.length; j++) {
192 var json = { 198 var json = {
193 idPedido: data.data.id, 199 idPedido: data.data.id,
194 dias: plazos[j].dias 200 dias: plazos[j].dias
195 }; 201 };
196 crearNotaPedidoService.crearPlazosParaNotaPedido(json); 202 crearNotaPedidoService.crearPlazosParaNotaPedido(json);
197 } 203 }
198 notaPedidoBusinessService.addEstado(data.data.id, 204 notaPedidoBusinessService.addEstado(data.data.id,
199 $scope.notaPedido.vendedor.codigo); 205 $scope.notaPedido.vendedor.codigo);
200 206
201 focaModalService.alert('Nota pedido creada'); 207 focaModalService.alert('Nota pedido creada');
202 $scope.cabecera = []; 208 $scope.cabecera = [];
203 addCabecera('Moneda:', $scope.notaPedido.moneda.detalle); 209 addCabecera('Moneda:', $scope.notaPedido.moneda.detalle);
204 addCabecera( 210 addCabecera(
205 'Fecha cotizacion:', 211 'Fecha cotizacion:',
206 $filter('date')($scope.notaPedido.cotizacion.FECHA, 'dd/MM/yyyy') 212 $filter('date')($scope.notaPedido.cotizacion.FECHA, 'dd/MM/yyyy')
207 ); 213 );
208 addCabecera('Cotizacion:', $scope.notaPedido.cotizacion.VENDEDOR); 214 addCabecera('Cotizacion:', $scope.notaPedido.cotizacion.VENDEDOR);
209 $scope.notaPedido.vendedor = {}; 215 $scope.notaPedido.vendedor = {};
210 $scope.notaPedido.cliente = {}; 216 $scope.notaPedido.cliente = {};
211 $scope.notaPedido.proveedor = {}; 217 $scope.notaPedido.proveedor = {};
212 $scope.notaPedido.domicilio = {}; 218 $scope.notaPedido.domicilio = {};
213 $scope.notaPedido.flete = null; 219 $scope.notaPedido.flete = null;
214 $scope.notaPedido.fob = null; 220 $scope.notaPedido.fob = null;
221 $scope.notaPedido.bomba = null;
222 $scope.notaPedido.kilometros = null;
223 $scope.articulosTabla = [];
224 },
225 function(error) {
226 focaModalService.alert('Hubo un error al crear la nota de pedido');
227 console.info(error);
228 }
229 );
230 };
231
232 $scope.seleccionarNotaPedido = function() {
233 var modalInstance = $uibModal.open(
234 {
235 ariaLabelledBy: 'Busqueda de Nota de Pedido',
236 templateUrl: 'foca-modal-nota-pedido.html',
237 controller: 'focaModalNotaPedidoController',
238 size: 'lg'
239 }
240 );
241 modalInstance.result.then(
242 function(notaPedido) {
243 //añado cabeceras
244 $scope.notaPedido.id = notaPedido.id;
245 removeCabecera('Moneda:');
246 removeCabecera('Fecha cotizacion:');
247 removeCabecera('Cotizacion:');
248 var cabeceras = [
249 {
250 label: 'Moneda',
251 valor: notaPedido.cotizacion[0].moneda[0].DETALLE
252 },
253 {
254 label: 'Fecha cotizacion',
255 valor: $filter('date')(notaPedido.cotizacion[0].FECHA,
256 'dd/MM/yyyy')
257 },
258 {
259 label: 'Cotizacion',
260 valor: notaPedido.cotizacion[0].VENDEDOR
261 },
262 {
263 label: 'Cliente:',
264 valor: notaPedido.cliente[0].NOM
265 },
266 {
267 label: 'Domicilio:',
268 valor: notaPedido.domicilioStamp
269 },
270 {
271 label: 'Vendedor:',
272 valor: notaPedido.vendedor[0].NomVen
273 },
274 {
275 label: 'Proveedor:',
276 valor: notaPedido.proveedor[0].NOM
277 },
278 {
279 label: 'Flete:',
280 valor: notaPedido.flete === 1 ? 'Si' : 'No'
281 },
282 {
283 label: 'FOB:',
284 valor: notaPedido.fob === 1 ? 'Si' : 'No'
285 },
286 {
287 label: 'Precio condicion:',
288 valor: valorPrecioCondicion()
215 $scope.notaPedido.bomba = null; 289 }
290 ];
291 //TODO MOSTRAR PLAZOS
292 function valorPrecioCondicion() {
293 if(notaPedido.idPrecioCondicion > 0) {
294 return notaPedido.precioCondicion[0].nombre;
295 } else {
296 return 'Ingreso Manual';
297 }
298 }
299
300 if(notaPedido.flete === 1) {
301 var cabeceraBomba = {
302 label: 'Bomba',
303 valor: notaPedido.bomba === 1 ? 'Si' : 'No'
304 };
305 if(notaPedido.kilometros) {
306 var cabeceraKilometros = {
307 label: 'Kilometros',
308 valor: notaPedido.kilometros
309 };
310 cabeceras.push(cabeceraKilometros);
311 }
312 cabeceras.push(cabeceraBomba);
313 }
314 $scope.articulosTabla = notaPedido.articulosNotaPedido;
315 if(notaPedido.precioCondicion.length > 0) {
316 $scope.idLista = notaPedido.precioCondicion[0].idListaPrecio;
317 } else {
318 $scope.idLista = -1;
319 }
320 $scope.comprobante = rellenar(notaPedido.numeroNotaPedido, 8);
321 $scope.notaPedido = notaPedido;
322 $scope.notaPedido.vendedor = notaPedido.vendedor[0];
323 $scope.notaPedido.cliente = notaPedido.cliente[0];
324 $scope.notaPedido.proveedor = notaPedido.proveedor[0];
325 $scope.notaPedido.moneda = notaPedido.cotizacion[0].moneda[0];
216 $scope.notaPedido.kilometros = null; 326 $scope.notaPedido.cotizacion = notaPedido.cotizacion[0];
217 $scope.articulosTabla = []; 327 $scope.plazosPagos = notaPedido.plazoPago;
218 }, 328 addArrayCabecera(cabeceras);
219 function(error) { 329
220 focaModalService.alert('Hubo un error al crear la nota de pedido'); 330 }, function() {
221 console.info(error); 331 // funcion ejecutada cuando se cancela el modal
222 } 332 }
223 ); 333 );
224 }; 334 }
225 335
226 $scope.seleccionarArticulo = function() { 336 $scope.seleccionarArticulo = function() {
227 if ($scope.idLista === undefined) { 337 if ($scope.idLista === undefined) {
228 focaModalService.alert( 338 focaModalService.alert(
229 'Primero seleccione una lista de precio y condicion'); 339 'Primero seleccione una lista de precio y condicion');
230 return; 340 return;
231 } 341 }
232 var modalInstance = $uibModal.open( 342 var modalInstance = $uibModal.open(
233 { 343 {
234 ariaLabelledBy: 'Busqueda de Productos', 344 ariaLabelledBy: 'Busqueda de Productos',
235 templateUrl: 'modal-busqueda-productos.html', 345 templateUrl: 'modal-busqueda-productos.html',
236 controller: 'modalBusquedaProductosCtrl', 346 controller: 'modalBusquedaProductosCtrl',
237 resolve: { 347 resolve: {
238 parametroProducto: { 348 parametroProducto: {
239 idLista: $scope.idLista, 349 idLista: $scope.idLista,
240 cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, 350 cotizacion: $scope.notaPedido.cotizacion.VENDEDOR,
241 simbolo: $scope.notaPedido.moneda.simbolo 351 simbolo: $scope.notaPedido.moneda.simbolo
242 } 352 }
243 }, 353 },
244 size: 'lg' 354 size: 'lg'
245 } 355 }
246 ); 356 );
247 modalInstance.result.then( 357 modalInstance.result.then(
248 function(producto) { 358 function(producto) {
249 var newArt = 359 var newArt =
250 { 360 {
251 id: 0, 361 id: 0,
252 codigo: producto.codigo, 362 codigo: producto.codigo,
253 sector: producto.sector, 363 sector: producto.sector,
254 sectorCodigo: producto.sector + '-' + producto.codigo, 364 sectorCodigo: producto.sector + '-' + producto.codigo,
255 descripcion: producto.descripcion, 365 descripcion: producto.descripcion,
256 item: $scope.articulosTabla.length + 1, 366 item: $scope.articulosTabla.length + 1,
257 nombre: producto.descripcion, 367 nombre: producto.descripcion,
258 precio: parseFloat(producto.precio.toFixed(4)), 368 precio: parseFloat(producto.precio.toFixed(4)),
259 costoUnitario: producto.costo, 369 costoUnitario: producto.costo,
260 editCantidad: false, 370 editCantidad: false,
261 editPrecio: false, 371 editPrecio: false,
262 rubro: producto.CodRub, 372 rubro: producto.CodRub,
263 exentoUnitario: producto.precio, 373 exentoUnitario: producto.precio,
264 ivaUnitario: producto.IMPIVA, 374 ivaUnitario: producto.IMPIVA,
265 impuestoInternoUnitario: producto.ImpInt, 375 impuestoInternoUnitario: producto.ImpInt,
266 impuestoInterno1Unitario: producto.ImpInt2, 376 impuestoInterno1Unitario: producto.ImpInt2,
267 impuestoInterno2Unitario: producto.ImpInt3, 377 impuestoInterno2Unitario: producto.ImpInt3,
268 precioLista: producto.precio, 378 precioLista: producto.precio,
269 combustible: 1, 379 combustible: 1,
270 facturado: 0 380 facturado: 0
271 }; 381 };
272 $scope.articuloACargar = newArt; 382 $scope.articuloACargar = newArt;
273 $scope.cargando = false; 383 $scope.cargando = false;
274 }, function() { 384 }, function() {
275 // funcion ejecutada cuando se cancela el modal 385 // funcion ejecutada cuando se cancela el modal
276 } 386 }
277 ); 387 );
278 }; 388 };
279 389
280 $scope.seleccionarVendedor = function() { 390 $scope.seleccionarVendedor = function() {
281 var modalInstance = $uibModal.open( 391 var modalInstance = $uibModal.open(
282 { 392 {
283 ariaLabelledBy: 'Busqueda de Vendedores', 393 ariaLabelledBy: 'Busqueda de Vendedores',
284 templateUrl: 'modal-vendedores.html', 394 templateUrl: 'modal-vendedores.html',
285 controller: 'modalVendedoresCtrl', 395 controller: 'modalVendedoresCtrl',
286 size: 'lg' 396 size: 'lg'
287 } 397 }
288 ); 398 );
289 modalInstance.result.then( 399 modalInstance.result.then(
290 function(vendedor) { 400 function(vendedor) {
291 addCabecera('Vendedor:', vendedor.NomVen); 401 addCabecera('Vendedor:', vendedor.NomVen);
292 $scope.notaPedido.vendedor.codigo = vendedor.CodVen; 402 $scope.notaPedido.vendedor = vendedor;
293 }, function() { 403 }, function() {
294 404
295 } 405 }
296 ); 406 );
297 }; 407 };
298 408
299 $scope.seleccionarProveedor = function() { 409 $scope.seleccionarProveedor = function() {
300 var modalInstance = $uibModal.open( 410 var modalInstance = $uibModal.open(
301 { 411 {
302 ariaLabelledBy: 'Busqueda de Proveedor', 412 ariaLabelledBy: 'Busqueda de Proveedor',
303 templateUrl: 'modal-proveedor.html', 413 templateUrl: 'modal-proveedor.html',
304 controller: 'focaModalProveedorCtrl', 414 controller: 'focaModalProveedorCtrl',
305 size: 'lg', 415 size: 'lg',
306 resolve: { 416 resolve: {
307 transportista: function() { 417 transportista: function() {
308 return false; 418 return false;
309 } 419 }
310 } 420 }
311 } 421 }
312 ); 422 );
313 modalInstance.result.then( 423 modalInstance.result.then(
314 function(proveedor) { 424 function(proveedor) {
315 $scope.notaPedido.proveedor.codigo = proveedor.COD; 425 $scope.notaPedido.proveedor = proveedor;
316 addCabecera('Proveedor:', proveedor.NOM); 426 addCabecera('Proveedor:', proveedor.NOM);
317 }, function() { 427 }, function() {
318 428
319 } 429 }
320 ); 430 );
321 }; 431 };
322 432
323 $scope.seleccionarCliente = function() { 433 $scope.seleccionarCliente = function() {
324 434
325 var modalInstance = $uibModal.open( 435 var modalInstance = $uibModal.open(
326 { 436 {
327 ariaLabelledBy: 'Busqueda de Cliente', 437 ariaLabelledBy: 'Busqueda de Cliente',
328 templateUrl: 'foca-busqueda-cliente-modal.html', 438 templateUrl: 'foca-busqueda-cliente-modal.html',
329 controller: 'focaBusquedaClienteModalController', 439 controller: 'focaBusquedaClienteModalController',
330 size: 'lg' 440 size: 'lg'
331 } 441 }
332 ); 442 );
333 modalInstance.result.then( 443 modalInstance.result.then(
334 function(cliente) { 444 function(cliente) {
335 $scope.abrirModalDomicilios(cliente); 445 $scope.abrirModalDomicilios(cliente);
336 }, function() { 446 }, function() {
337 447
338 } 448 }
339 ); 449 );
340 }; 450 };
341 451
342 $scope.abrirModalDomicilios = function(cliente) { 452 $scope.abrirModalDomicilios = function(cliente) {
343 var modalInstanceDomicilio = $uibModal.open( 453 var modalInstanceDomicilio = $uibModal.open(
344 { 454 {
345 ariaLabelledBy: 'Busqueda de Domicilios', 455 ariaLabelledBy: 'Busqueda de Domicilios',
456 templateUrl: 'modal-domicilio.html',
457 controller: 'focaModalDomicilioController',
458 resolve: { idCliente: function() { return cliente.cod; }},
459 size: 'lg',
346 templateUrl: 'modal-domicilio.html', 460 }
347 controller: 'focaModalDomicilioController', 461 );
348 resolve: { idCliente: function() { return cliente.cod; }}, 462 modalInstanceDomicilio.result.then(
349 size: 'lg', 463 function(domicilio) {
350 } 464 $scope.notaPedido.domicilio = domicilio;
351 ); 465 $scope.notaPedido.cliente = {
352 modalInstanceDomicilio.result.then( 466 COD: cliente.cod,
353 function(domicilio) { 467 CUIT: cliente.cuit,
354 $scope.notaPedido.domicilio.id = domicilio.id; 468 NOM: cliente.nom
355 $scope.notaPedido.cliente = cliente; 469 };
356 addCabecera('Cliente:', cliente.nom); 470 addCabecera('Cliente:', cliente.nom);
357 var domicilioStamp = 471 var domicilioStamp =
358 domicilio.Calle + ' ' + domicilio.Numero + ', ' + 472 domicilio.Calle + ' ' + domicilio.Numero + ', ' +
359 domicilio.Localidad + ', ' + domicilio.Provincia; 473 domicilio.Localidad + ', ' + domicilio.Provincia;
360 $scope.notaPedido.domicilioStamp = domicilioStamp; 474 $scope.notaPedido.domicilioStamp = domicilioStamp;
361 addCabecera('Domicilio:', domicilioStamp); 475 addCabecera('Domicilio:', domicilioStamp);
362 }, function() { 476 }, function() {
363 $scope.seleccionarCliente(); 477 $scope.seleccionarCliente();
364 return; 478 return;
365 } 479 }
366 ); 480 );
367 }; 481 };
368 482
369 $scope.mostrarFichaCliente = function() { 483 $scope.mostrarFichaCliente = function() {
370 $uibModal.open( 484 $uibModal.open(
371 { 485 {
372 ariaLabelledBy: 'Datos del Cliente', 486 ariaLabelledBy: 'Datos del Cliente',
373 templateUrl: 'foca-crear-nota-pedido-ficha-cliente.html', 487 templateUrl: 'foca-crear-nota-pedido-ficha-cliente.html',
374 controller: 'focaCrearNotaPedidoFichaClienteController', 488 controller: 'focaCrearNotaPedidoFichaClienteController',
375 size: 'lg' 489 size: 'lg'
376 } 490 }
377 ); 491 );
378 }; 492 };
379 493
380 $scope.getTotal = function() { 494 $scope.getTotal = function() {
381 var total = 0; 495 var total = 0;
382 var arrayTempArticulos = $scope.articulosTabla; 496 var arrayTempArticulos = $scope.articulosTabla;
383 for (var i = 0; i < arrayTempArticulos.length; i++) { 497 for (var i = 0; i < arrayTempArticulos.length; i++) {
384 total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; 498 total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad;
385 } 499 }
386 return parseFloat(total.toFixed(2)); 500 return parseFloat(total.toFixed(2));
387 }; 501 };
388 502
389 $scope.getSubTotal = function() { 503 $scope.getSubTotal = function() {
390 if($scope.articuloACargar) { 504 if($scope.articuloACargar) {
391 return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; 505 return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad;
392 } 506 }
393 }; 507 };
394 508
395 $scope.abrirModalListaPrecio = function() { 509 $scope.abrirModalListaPrecio = function() {
396 var modalInstance = $uibModal.open( 510 var modalInstance = $uibModal.open(
397 { 511 {
398 ariaLabelledBy: 'Busqueda de Precio Condición', 512 ariaLabelledBy: 'Busqueda de Precio Condición',
399 templateUrl: 'modal-precio-condicion.html', 513 templateUrl: 'modal-precio-condicion.html',
400 controller: 'focaModalPrecioCondicionController', 514 controller: 'focaModalPrecioCondicionController',
401 size: 'lg' 515 size: 'lg'
402 } 516 }
403 ); 517 );
404 modalInstance.result.then( 518 modalInstance.result.then(
405 function(precioCondicion) { 519 function(precioCondicion) {
406 var cabecera = ''; 520 var cabecera = '';
407 var plazosConcat = ''; 521 var plazosConcat = '';
408 if(!Array.isArray(precioCondicion)) { 522 if(!Array.isArray(precioCondicion)) {
409 $scope.notaPedido.idPrecioCondicion = precioCondicion.id; 523 $scope.notaPedido.idPrecioCondicion = precioCondicion.id;
410 $scope.plazosPagos = precioCondicion.plazoPago; 524 $scope.plazosPagos = precioCondicion.plazoPago;
411 $scope.idLista = precioCondicion.idListaPrecio; 525 $scope.idLista = precioCondicion.idListaPrecio;
412 for(var i = 0; i < precioCondicion.plazoPago.length; i++) { 526 for(var i = 0; i < precioCondicion.plazoPago.length; i++) {
413 plazosConcat += precioCondicion.plazoPago[i].dias + ' '; 527 plazosConcat += precioCondicion.plazoPago[i].dias + ' ';
414 } 528 }
415 cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); 529 cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim();
416 } else { //Cuando se ingresan los plazos manualmente 530 } else { //Cuando se ingresan los plazos manualmente
417 $scope.notaPedido.idPrecioCondicion = 0; 531 $scope.notaPedido.idPrecioCondicion = 0;
418 $scope.idLista = -1; //-1, el modal productos busca todos los productos 532 $scope.idLista = -1; //-1, el modal productos busca todos los productos
419 $scope.plazosPagos = precioCondicion; 533 $scope.plazosPagos = precioCondicion;
420 for(var j = 0; j < precioCondicion.length; j++) { 534 for(var j = 0; j < precioCondicion.length; j++) {
421 plazosConcat += precioCondicion[j].dias + ' '; 535 plazosConcat += precioCondicion[j].dias + ' ';
422 } 536 }
423 cabecera = 'Ingreso manual ' + plazosConcat.trim(); 537 cabecera = 'Ingreso manual ' + plazosConcat.trim();
424 } 538 }
425 $scope.articulosTabla = []; 539 $scope.articulosTabla = [];
426 addCabecera('Precios y condiciones:', cabecera); 540 addCabecera('Precios y condiciones:', cabecera);
427 }, function() { 541 }, function() {
428 542
429 } 543 }
430 ); 544 );
431 }; 545 };
432 546
433 $scope.abrirModalFlete = function() { 547 $scope.abrirModalFlete = function() {
434 var modalInstance = $uibModal.open( 548 var modalInstance = $uibModal.open(
435 { 549 {
436 ariaLabelledBy: 'Busqueda de Flete', 550 ariaLabelledBy: 'Busqueda de Flete',
437 templateUrl: 'modal-flete.html', 551 templateUrl: 'modal-flete.html',
438 controller: 'focaModalFleteController', 552 controller: 'focaModalFleteController',
439 size: 'lg', 553 size: 'lg',
440 resolve: { 554 resolve: {
441 parametrosFlete: 555 parametrosFlete:
442 function() { 556 function() {
443 return { 557 return {
444 flete: $scope.notaPedido.flete ? '1' : 558 flete: $scope.notaPedido.flete ? '1' :
445 ($scope.notaPedido.fob ? 'FOB' : 559 ($scope.notaPedido.fob ? 'FOB' :
446 ($scope.notaPedido.flete === undefined ? null : '0')), 560 ($scope.notaPedido.flete === undefined ? null : '0')),
447 bomba: $scope.notaPedido.bomba ? '1' : 561 bomba: $scope.notaPedido.bomba ? '1' :
448 ($scope.notaPedido.bomba === undefined ? null : '0'), 562 ($scope.notaPedido.bomba === undefined ? null : '0'),
449 kilometros: $scope.notaPedido.kilometros 563 kilometros: $scope.notaPedido.kilometros
450 }; 564 };
451 } 565 }
452 } 566 }
453 } 567 }
454 ); 568 );
455 modalInstance.result.then( 569 modalInstance.result.then(
456 function(datos) { 570 function(datos) {
457 $scope.notaPedido.flete = datos.flete; 571 $scope.notaPedido.flete = datos.flete;
458 $scope.notaPedido.fob = datos.FOB; 572 $scope.notaPedido.fob = datos.FOB;
459 $scope.notaPedido.bomba = datos.bomba; 573 $scope.notaPedido.bomba = datos.bomba;
460 $scope.notaPedido.kilometros = datos.kilometros; 574 $scope.notaPedido.kilometros = datos.kilometros;
461 575
462 addCabecera('Flete:', datos.flete ? 'Si' : 576 addCabecera('Flete:', datos.flete ? 'Si' :
463 ($scope.notaPedido.fob ? 'FOB' : 'No')); 577 ($scope.notaPedido.fob ? 'FOB' : 'No'));
464 if(datos.flete) { 578 if(datos.flete) {
465 addCabecera('Bomba:', datos.bomba ? 'Si' : 'No'); 579 addCabecera('Bomba:', datos.bomba ? 'Si' : 'No');
466 addCabecera('Kilometros:', datos.kilometros); 580 addCabecera('Kilometros:', datos.kilometros);
467 } else { 581 } else {
468 removeCabecera('Bomba:'); 582 removeCabecera('Bomba:');
469 removeCabecera('Kilometros:'); 583 removeCabecera('Kilometros:');
470 $scope.notaPedido.fob = false; 584 $scope.notaPedido.fob = false;
471 $scope.notaPedido.bomba = false; 585 $scope.notaPedido.bomba = false;
472 $scope.notaPedido.kilometros = null; 586 $scope.notaPedido.kilometros = null;
473 } 587 }
474 }, function() { 588 }, function() {
475 589
476 } 590 }
477 ); 591 );
478 }; 592 };
479 593
480 $scope.abrirModalMoneda = function() { 594 $scope.abrirModalMoneda = function() {
481 var modalInstance = $uibModal.open( 595 var modalInstance = $uibModal.open(
482 { 596 {
483 ariaLabelledBy: 'Busqueda de Moneda', 597 ariaLabelledBy: 'Busqueda de Moneda',
484 templateUrl: 'modal-moneda.html', 598 templateUrl: 'modal-moneda.html',
485 controller: 'focaModalMonedaController', 599 controller: 'focaModalMonedaController',
486 size: 'lg' 600 size: 'lg'
487 } 601 }
488 ); 602 );
489 modalInstance.result.then( 603 modalInstance.result.then(
490 function(moneda) { 604 function(moneda) {
491 $scope.abrirModalCotizacion(moneda); 605 $scope.abrirModalCotizacion(moneda);
492 }, function() { 606 }, function() {
493 607
494 } 608 }
495 ); 609 );
496 }; 610 };
497 611
498 $scope.abrirModalCotizacion = function(moneda) { 612 $scope.abrirModalCotizacion = function(moneda) {
499 var modalInstance = $uibModal.open( 613 var modalInstance = $uibModal.open(
500 { 614 {
501 ariaLabelledBy: 'Busqueda de Cotización', 615 ariaLabelledBy: 'Busqueda de Cotización',
502 templateUrl: 'modal-cotizacion.html', 616 templateUrl: 'modal-cotizacion.html',
503 controller: 'focaModalCotizacionController', 617 controller: 'focaModalCotizacionController',
504 size: 'lg', 618 size: 'lg',
505 resolve: {idMoneda: function() {return moneda.ID;}} 619 resolve: {idMoneda: function() {return moneda.ID;}}
506 } 620 }
507 ); 621 );
508 modalInstance.result.then( 622 modalInstance.result.then(
509 function(cotizacion) {
510 var articulosTablaTemp = $scope.articulosTabla;
511 for(var i = 0; i < articulosTablaTemp.length; i++) {
512 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio *
513 $scope.notaPedido.cotizacion.VENDEDOR; 623 function(cotizacion) {
514 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / 624 var articulosTablaTemp = $scope.articulosTabla;
515 cotizacion.VENDEDOR; 625 for(var i = 0; i < articulosTablaTemp.length; i++) {
516 } 626 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio *
517 $scope.articulosTabla = articulosTablaTemp; 627 $scope.notaPedido.cotizacion.VENDEDOR;
518 $scope.notaPedido.moneda = { 628 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio /
519 id: moneda.ID, 629 cotizacion.VENDEDOR;
520 detalle: moneda.DETALLE, 630 }
521 simbolo: moneda.SIMBOLO 631 $scope.articulosTabla = articulosTablaTemp;
522 }; 632 $scope.notaPedido.moneda = moneda;
523 $scope.notaPedido.cotizacion = cotizacion; 633 $scope.notaPedido.cotizacion = cotizacion;
524 addCabecera('Moneda:', moneda.DETALLE); 634 addCabecera('Moneda:', moneda.DETALLE);
525 addCabecera( 635 addCabecera(
526 'Fecha cotizacion:', 636 'Fecha cotizacion:',
527 $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') 637 $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy')
528 ); 638 );
529 addCabecera('Cotizacion:', cotizacion.VENDEDOR); 639 addCabecera('Cotizacion:', cotizacion.VENDEDOR);
530 }, function() { 640 }, function() {
531 641
532 } 642 }
533 ); 643 );
534 }; 644 };
535 645
536 $scope.agregarATabla = function(key) { 646 $scope.agregarATabla = function(key) {
537 if(key === 13) { 647 if(key === 13) {
538 if($scope.articuloACargar.cantidad === undefined || 648 if($scope.articuloACargar.cantidad === undefined ||
539 $scope.articuloACargar.cantidad === 0 || 649 $scope.articuloACargar.cantidad === 0 ||
540 $scope.articuloACargar.cantidad === null ) { 650 $scope.articuloACargar.cantidad === null ) {
541 focaModalService.alert('El valor debe ser al menos 1'); 651 focaModalService.alert('El valor debe ser al menos 1');
542 return; 652 return;
543 } 653 }
544 delete $scope.articuloACargar.sectorCodigo; 654 delete $scope.articuloACargar.sectorCodigo;
545 $scope.articulosTabla.push($scope.articuloACargar); 655 $scope.articulosTabla.push($scope.articuloACargar);
546 $scope.cargando = true; 656 $scope.cargando = true;
547 } 657 }
548 }; 658 };
549 659
550 $scope.quitarArticulo = function(key) { 660 $scope.quitarArticulo = function(key) {
551 $scope.articulosTabla.splice(key, 1); 661 $scope.articulosTabla.splice(key, 1);
552 }; 662 };
553 663
554 $scope.editarArticulo = function(key, articulo) { 664 $scope.editarArticulo = function(key, articulo) {
555 if(key === 13) { 665 if(key === 13) {
556 if(articulo.cantidad === null || articulo.cantidad === 0 || 666 if(articulo.cantidad === null || articulo.cantidad === 0 ||
557 articulo.cantidad === undefined) { 667 articulo.cantidad === undefined) {
558 focaModalService.alert('El valor debe ser al menos 1'); 668 focaModalService.alert('El valor debe ser al menos 1');
559 return; 669 return;
560 } 670 }
561 articulo.editCantidad = false; 671 articulo.editCantidad = false;
562 articulo.editPrecio = false; 672 articulo.editPrecio = false;
563 } 673 }
564 }; 674 };
565 675
566 $scope.cambioEdit = function(articulo, propiedad) { 676 $scope.cambioEdit = function(articulo, propiedad) {
567 if(propiedad === 'cantidad') { 677 if(propiedad === 'cantidad') {
568 articulo.editCantidad = true; 678 articulo.editCantidad = true;
569 } else if(propiedad === 'precio') { 679 } else if(propiedad === 'precio') {
570 articulo.editPrecio = true; 680 articulo.editPrecio = true;
571 } 681 }
572 }; 682 };
573 683
574 $scope.limpiarFlete = function() { 684 $scope.limpiarFlete = function() {
575 $scope.notaPedido.fleteNombre = ''; 685 $scope.notaPedido.fleteNombre = '';
576 $scope.notaPedido.chofer = ''; 686 $scope.notaPedido.chofer = '';
577 $scope.notaPedido.vehiculo = ''; 687 $scope.notaPedido.vehiculo = '';
578 $scope.notaPedido.kilometros = ''; 688 $scope.notaPedido.kilometros = '';
579 $scope.notaPedido.costoUnitarioKmFlete = ''; 689 $scope.notaPedido.costoUnitarioKmFlete = '';
580 $scope.choferes = ''; 690 $scope.choferes = '';
581 $scope.vehiculos = ''; 691 $scope.vehiculos = '';
582 }; 692 };
583 693
584 $scope.limpiarPantalla = function() { 694 $scope.limpiarPantalla = function() {
585 $scope.limpiarFlete(); 695 $scope.limpiarFlete();
586 $scope.notaPedido.flete = '0'; 696 $scope.notaPedido.flete = '0';
587 $scope.notaPedido.bomba = '0'; 697 $scope.notaPedido.bomba = '0';
588 $scope.notaPedido.precioCondicion = ''; 698 $scope.notaPedido.precioCondicion = '';
589 $scope.articulosTabla = []; 699 $scope.articulosTabla = [];
590 $scope.notaPedido.vendedor.nombre = ''; 700 $scope.notaPedido.vendedor.nombre = '';
591 $scope.notaPedido.cliente = {nombre: ''}; 701 $scope.notaPedido.cliente = {nombre: ''};
592 $scope.notaPedido.domicilio = {dom: ''}; 702 $scope.notaPedido.domicilio = {dom: ''};
593 $scope.domiciliosCliente = []; 703 $scope.domiciliosCliente = [];
594 }; 704 };
595 705
596 $scope.resetFilter = function() { 706 $scope.resetFilter = function() {
597 $scope.articuloACargar = {}; 707 $scope.articuloACargar = {};
598 $scope.cargando = true; 708 $scope.cargando = true;
599 }; 709 };
600 //Recibe aviso si el teclado está en uso 710 //Recibe aviso si el teclado está en uso
601 $rootScope.$on('usarTeclado', function(event, data) { 711 $rootScope.$on('usarTeclado', function(event, data) {
602 if(data) { 712 if(data) {
603 $scope.mostrarTeclado = true; 713 $scope.mostrarTeclado = true;
604 return; 714 return;
605 } 715 }
606 $scope.mostrarTeclado = false; 716 $scope.mostrarTeclado = false;
607 }); 717 });
608 718
609 $scope.selectFocus = function($event) { 719 $scope.selectFocus = function($event) {
610 // Si el teclado esta en uso no selecciona el valor 720 // Si el teclado esta en uso no selecciona el valor
611 if($scope.mostrarTeclado) { 721 if($scope.mostrarTeclado) {
612 return; 722 return;
613 } 723 }
614 $event.target.select(); 724 $event.target.select();
725 };
726
727 $scope.salir = function() {
728 $location.path('/');
729 };
730
615 }; 731 $scope.parsearATexto = function(articulo) {
616 732 articulo.cantidad = parseFloat(articulo.cantidad);
617 $scope.salir = function() { 733 articulo.precio = parseFloat(articulo.precio);
618 $location.path('/'); 734 };
619 }; 735
620 736 function addArrayCabecera(array) {
621 $scope.parsearATexto = function(articulo) { 737 for(var i = 0; i < array.length; i++) {
622 articulo.cantidad = parseFloat(articulo.cantidad); 738 addCabecera(array[i].label, array[i].valor);
623 articulo.precio = parseFloat(articulo.precio); 739 }
624 }; 740 }
625 741
626 function addCabecera(label, valor) { 742 function addCabecera(label, valor) {
627 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); 743 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true);
628 if(propiedad.length === 1) { 744 if(propiedad.length === 1) {
629 propiedad[0].valor = valor; 745 propiedad[0].valor = valor;
630 } else { 746 } else {
631 $scope.cabecera.push({label: label, valor: valor}); 747 $scope.cabecera.push({label: label, valor: valor});
632 } 748 }
633 } 749 }
634 750
635 function removeCabecera(label) { 751 function removeCabecera(label) {
636 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); 752 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true);
637 if(propiedad.length === 1) { 753 if(propiedad.length === 1) {
638 $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); 754 $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1);
639 } 755 }
756 }
757
758 function rellenar(relleno, longitud) {
759 relleno = '' + relleno;
760 while (relleno.length < longitud) {
761 relleno = '0' + relleno;
762 }
763
764 return relleno;
640 } 765 }
641 766
642 function rellenar(relleno, longitud) { 767 function validarNotaRemitada(funcion) {
643 relleno = '' + relleno; 768 if($scope.notaPedido.idRemito) {
644 while (relleno.length < longitud) { 769 focaModalService.alert('No se puede editar una nota de pedido remitada');
645 relleno = '0' + relleno; 770 }
646 } 771 else {
647 772 funcion();
648 return relleno; 773 }
649 } 774 }
650 } 775 }
651 ] 776 ]
652 ) 777 )
653 .controller('notaPedidoListaCtrl', [ 778 .controller('notaPedidoListaCtrl', [
654 '$scope', 779 '$scope',
655 'crearNotaPedidoService', 780 'crearNotaPedidoService',
656 '$location', 781 '$location',
657 function($scope, crearNotaPedidoService, $location) { 782 function($scope, crearNotaPedidoService, $location) {
658 crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { 783 crearNotaPedidoService.obtenerNotaPedido().then(function(datos) {
659 $scope.notaPedidos = datos.data; 784 $scope.notaPedidos = datos.data;
660 }); 785 });
661 $scope.editar = function(notaPedido) { 786 $scope.editar = function(notaPedido) {
662 crearNotaPedidoService.setNotaPedido(notaPedido); 787 crearNotaPedidoService.setNotaPedido(notaPedido);
663 $location.path('/venta-nota-pedido/abm/'); 788 $location.path('/venta-nota-pedido/abm/');
664 }; 789 };
665 $scope.crearPedido = function() { 790 $scope.crearPedido = function() {
666 crearNotaPedidoService.clearNotaPedido(); 791 crearNotaPedidoService.clearNotaPedido();
667 $location.path('/venta-nota-pedido/abm/'); 792 $location.path('/venta-nota-pedido/abm/');
668 }; 793 };
669 } 794 }
670 ]) 795 ])
671 .controller('focaCrearNotaPedidoFichaClienteController', [ 796 .controller('focaCrearNotaPedidoFichaClienteController', [
672 '$scope', 797 '$scope',
673 'crearNotaPedidoService', 798 'crearNotaPedidoService',
674 '$location', 799 '$location',
675 function($scope, crearNotaPedidoService, $location) { 800 function($scope, crearNotaPedidoService, $location) {
676 crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { 801 crearNotaPedidoService.obtenerNotaPedido().then(function(datos) {
677 $scope.notaPedidos = datos.data; 802 $scope.notaPedidos = datos.data;
678 }); 803 });
679 $scope.editar = function(notaPedido) { 804 $scope.editar = function(notaPedido) {
680 crearNotaPedidoService.setNotaPedido(notaPedido); 805 crearNotaPedidoService.setNotaPedido(notaPedido);
681 $location.path('/venta-nota-pedido/abm/'); 806 $location.path('/venta-nota-pedido/abm/');
682 }; 807 };
683 $scope.crearPedido = function() { 808 $scope.crearPedido = function() {
684 crearNotaPedidoService.clearNotaPedido(); 809 crearNotaPedidoService.clearNotaPedido();
685 $location.path('/venta-nota-pedido/abm/'); 810 $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