Commit 68d481eac1dbf29227fc1c4572a1d8d95e511c18

Authored by Pablo Marco del Pont
Exists in master

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

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