Commit 8da07a79e7ac93a92da1748671346f9c74b9edb1

Authored by Jose Pinto
1 parent 399786fc57
Exists in master

Boton puntos de descarga

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