Commit 3bb31840ec7f41b5d596684eb28b49cf5a108479

Authored by Eric Fernandez
Exists in master and in 1 other branch develop

Merge branch 'master' into 'develop'

Master

See merge request !52
src/js/controller.js
1 angular.module('focaCrearRemito') .controller('remitoController', 1 angular.module('focaCrearRemito') .controller('remitoController',
2 [ 2 [
3 '$scope', '$uibModal', '$location', '$filter', 'crearRemitoService', '$timeout', 3 '$scope', '$uibModal', '$location', '$filter', 'crearRemitoService', '$timeout',
4 'focaModalService', 'remitoBusinessService', '$rootScope', 'focaBotoneraLateralService', 4 'focaModalService', 'remitoBusinessService', '$rootScope', 'focaBotoneraLateralService',
5 '$localStorage', 5 '$localStorage',
6 function( 6 function(
7 $scope, $uibModal, $location, $filter, crearRemitoService, $timeout, focaModalService, 7 $scope, $uibModal, $location, $filter, crearRemitoService, $timeout, focaModalService,
8 remitoBusinessService, $rootScope, focaBotoneraLateralService, $localStorage) 8 remitoBusinessService, $rootScope, focaBotoneraLateralService, $localStorage)
9 { 9 {
10 config(); 10 config();
11 11
12 function config() { 12 function config() {
13 $scope.botonera = crearRemitoService.getBotonera(); 13 $scope.botonera = crearRemitoService.getBotonera();
14 $scope.isNumber = angular.isNumber; 14 $scope.isNumber = angular.isNumber;
15 $scope.datepickerAbierto = false; 15 $scope.datepickerAbierto = false;
16 $scope.show = false; 16 $scope.show = false;
17 $scope.cargando = true; 17 $scope.cargando = true;
18 $scope.now = new Date(); 18 $scope.now = new Date();
19 $scope.puntoVenta = rellenar(0, 4); 19 $scope.puntoVenta = rellenar(0, 4);
20 $scope.comprobante = rellenar(0, 8); 20 $scope.comprobante = rellenar(0, 8);
21 $scope.dateOptions = { 21 $scope.dateOptions = {
22 maxDate: new Date(), 22 maxDate: new Date(),
23 minDate: new Date(2010, 0, 1) 23 minDate: new Date(2010, 0, 1)
24 }; 24 };
25 25
26 var monedaPorDefecto; 26 var monedaPorDefecto;
27 //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' 27 //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]'
28 crearRemitoService.getCotizacionByIdMoneda(1).then(function(res) { 28 crearRemitoService.getCotizacionByIdMoneda(1).then(function(res) {
29 monedaPorDefecto = res.data[0]; 29 monedaPorDefecto = res.data[0];
30 30
31 $scope.remito.cotizacion = Object.assign( 31 $scope.remito.cotizacion = Object.assign(
32 {moneda: monedaPorDefecto}, monedaPorDefecto.cotizaciones[0] 32 {moneda: monedaPorDefecto}, monedaPorDefecto.cotizaciones[0]
33 ); 33 );
34 $scope.inicial.cotizacion = $scope.remito.cotizacion; 34 $scope.inicial.cotizacion = $scope.remito.cotizacion;
35 $scope.cotizacionPorDefecto = angular.copy($scope.remito.cotizacion); 35 $scope.cotizacionPorDefecto = angular.copy($scope.remito.cotizacion);
36 }); 36 });
37 37
38 //SETEO BOTONERA LATERAL 38 //SETEO BOTONERA LATERAL
39 $timeout(function() { 39 $timeout(function() {
40 focaBotoneraLateralService.showSalir(false); 40 focaBotoneraLateralService.showSalir(false);
41 focaBotoneraLateralService.showPausar(true); 41 focaBotoneraLateralService.showPausar(true);
42 focaBotoneraLateralService.showGuardar(true, $scope.crearRemito); 42 focaBotoneraLateralService.showGuardar(true, $scope.crearRemito);
43 focaBotoneraLateralService.addCustomButton('Salir', salir); 43 focaBotoneraLateralService.addCustomButton('Salir', salir);
44 }); 44 });
45 45
46 init(); 46 init();
47 $timeout(function() {getLSRemito();}); 47 $timeout(function() {getLSRemito();});
48 } 48 }
49 49
50 function init() { 50 function init() {
51 $scope.$broadcast('cleanCabecera'); 51 $scope.$broadcast('cleanCabecera');
52 52
53 $scope.remito = { 53 $scope.remito = {
54 id: 0, 54 id: 0,
55 estado: 0, 55 estado: 0,
56 vendedor: {}, 56 vendedor: {},
57 cliente: {}, 57 cliente: {},
58 proveedor: {}, 58 proveedor: {},
59 domicilio: {dom: ''}, 59 domicilio: {dom: ''},
60 moneda: {}, 60 moneda: {},
61 cotizacion: $scope.cotizacionPorDefecto || {}, 61 cotizacion: $scope.cotizacionPorDefecto || {},
62 articulosRemito: [] 62 articulosRemito: []
63 }; 63 };
64 64
65 $scope.notaPedido = { 65 $scope.notaPedido = {
66 id: 0 66 id: 0
67 }; 67 };
68 68
69 $scope.remito.articulosRemito = []; 69 $scope.remito.articulosRemito = [];
70 $scope.idLista = undefined; 70 $scope.idLista = undefined;
71 71
72 crearRemitoService.getNumeroRemito().then( 72 crearRemitoService.getNumeroRemito().then(
73 function(res) { 73 function(res) {
74 $scope.puntoVenta = rellenar(res.data.sucursal, 4); 74 $scope.puntoVenta = rellenar(res.data.sucursal, 4);
75 $scope.comprobante = rellenar(res.data.numeroRemito, 8); 75 $scope.comprobante = rellenar(res.data.numeroRemito, 8);
76 }, 76 },
77 function(err) { 77 function(err) {
78 focaModalService.alert('La terminal no esta configurada correctamente'); 78 focaModalService.alert('La terminal no esta configurada correctamente');
79 console.info(err); 79 console.info(err);
80 } 80 }
81 ); 81 );
82 82
83 $scope.inicial = angular.copy($scope.remito); 83 $scope.inicial = angular.copy($scope.remito);
84 } 84 }
85 85
86 $scope.$watch('remito', function(newValue) { 86 $scope.$watch('remito', function(newValue) {
87 focaBotoneraLateralService.setPausarData({ 87 focaBotoneraLateralService.setPausarData({
88 label: 'remito', 88 label: 'remito',
89 val: newValue 89 val: newValue
90 }); 90 });
91 }, true); 91 }, true);
92 92
93 $scope.seleccionarNotaPedido = function() { 93 $scope.seleccionarNotaPedido = function() {
94 if(varlidarRemitoFacturado()) { 94 if(varlidarRemitoFacturado()) {
95 var modalInstance = $uibModal.open( 95 var modalInstance = $uibModal.open(
96 { 96 {
97 ariaLabelledBy: 'Busqueda de Nota de Pedido', 97 ariaLabelledBy: 'Busqueda de Nota de Pedido',
98 templateUrl: 'foca-modal-nota-pedido.html', 98 templateUrl: 'foca-modal-nota-pedido.html',
99 controller: 'focaModalNotaPedidoController', 99 controller: 'focaModalNotaPedidoController',
100 size: 'lg', 100 size: 'lg',
101 resolve: { 101 resolve: {
102 usadoPor: function() { return 'remito'; }, 102 usadoPor: function() { return 'remito'; },
103 idVendedor: function() { return null; } 103 idVendedor: function() { return null; }
104 } 104 }
105 } 105 }
106 ); 106 );
107 modalInstance.result.then( 107 modalInstance.result.then(
108 function(notaPedido) { 108 function(notaPedido) {
109 //añado cabeceras 109 //añado cabeceras
110 $scope.notaPedido.id = notaPedido.id; 110 $scope.notaPedido.id = notaPedido.id;
111 $scope.$broadcast('removeCabecera', 'Bomba:'); 111 $scope.$broadcast('removeCabecera', 'Bomba:');
112 $scope.$broadcast('removeCabecera', 'Kilometros:'); 112 $scope.$broadcast('removeCabecera', 'Kilometros:');
113 var cabeceras = [ 113 var cabeceras = [
114 { 114 {
115 label: 'Moneda:', 115 label: 'Moneda:',
116 valor: notaPedido.cotizacion.moneda.DETALLE 116 valor: notaPedido.cotizacion.moneda.DETALLE
117 }, 117 },
118 { 118 {
119 label: 'Fecha cotizacion:', 119 label: 'Fecha cotizacion:',
120 valor: $filter('date')(notaPedido.cotizacion.FECHA, 120 valor: $filter('date')(notaPedido.cotizacion.FECHA,
121 'dd/MM/yyyy') 121 'dd/MM/yyyy')
122 }, 122 },
123 { 123 {
124 label: 'Cotizacion:', 124 label: 'Cotizacion:',
125 valor: $filter('number')(notaPedido.cotizacion.VENDEDOR, 125 valor: $filter('number')(notaPedido.cotizacion.VENDEDOR,
126 '2') 126 '2')
127 }, 127 },
128 { 128 {
129 label: 'Cliente:', 129 label: 'Cliente:',
130 valor: $filter('rellenarDigitos')(notaPedido.cliente.COD, 3) + 130 valor: $filter('rellenarDigitos')(notaPedido.cliente.COD, 3) +
131 ' - ' + notaPedido.cliente.NOM 131 ' - ' + notaPedido.cliente.NOM
132 }, 132 },
133 { 133 {
134 label: 'Domicilio:', 134 label: 'Domicilio:',
135 valor: notaPedido.domicilioStamp 135 valor: notaPedido.domicilioStamp
136 }, 136 },
137 { 137 {
138 label: 'Vendedor:', 138 label: 'Vendedor:',
139 valor: $filter('rellenarDigitos')( 139 valor: $filter('rellenarDigitos')(
140 notaPedido.vendedor.NUM, 3 140 notaPedido.vendedor.NUM, 3
141 ) + ' - ' + notaPedido.vendedor.NOM 141 ) + ' - ' + notaPedido.vendedor.NOM
142 }, 142 },
143 { 143 {
144 label: 'Proveedor:', 144 label: 'Proveedor:',
145 valor: $filter('rellenarDigitos') 145 valor: $filter('rellenarDigitos')
146 (notaPedido.proveedor.COD, 5) + ' - ' + 146 (notaPedido.proveedor.COD, 5) + ' - ' +
147 notaPedido.proveedor.NOM 147 notaPedido.proveedor.NOM
148 }, 148 },
149 { 149 {
150 label: 'Precio condicion:', 150 label: 'Precio condicion:',
151 valor: valorPrecioCondicion() + ' ' + 151 valor: valorPrecioCondicion() + ' ' +
152 remitoBusinessService 152 remitoBusinessService
153 .plazoToString(notaPedido.notaPedidoPlazo) 153 .plazoToString(notaPedido.notaPedidoPlazo)
154 }, 154 },
155 { 155 {
156 label: 'Flete:', 156 label: 'Flete:',
157 valor: notaPedido.fob === 1 ? 'FOB' : ( 157 valor: notaPedido.fob === 1 ? 'FOB' : (
158 notaPedido.flete === 1 ? 'Si' : 'No') 158 notaPedido.flete === 1 ? 'Si' : 'No')
159 } 159 }
160 ]; 160 ];
161 161
162 if (notaPedido.observaciones) { 162 if (notaPedido.observaciones) {
163 cabeceras.push({ 163 cabeceras.push({
164 label: 'Observaciones:', 164 label: 'Observaciones:',
165 valor: notaPedido.observaciones 165 valor: notaPedido.observaciones
166 }); 166 });
167 } 167 }
168 168
169 function valorPrecioCondicion() { 169 function valorPrecioCondicion() {
170 if (notaPedido.idPrecioCondicion > 0) { 170 if (notaPedido.idPrecioCondicion > 0) {
171 return notaPedido.precioCondicion.nombre; 171 return notaPedido.precioCondicion.nombre;
172 } else { 172 } else {
173 return 'Ingreso Manual'; 173 return 'Ingreso Manual';
174 } 174 }
175 } 175 }
176 176
177 if (notaPedido.flete === 1) { 177 if (notaPedido.flete === 1) {
178 var cabeceraBomba = { 178 var cabeceraBomba = {
179 label: 'Bomba:', 179 label: 'Bomba:',
180 valor: notaPedido.bomba === 1 ? 'Si' : 'No' 180 valor: notaPedido.bomba === 1 ? 'Si' : 'No'
181 }; 181 };
182 if (notaPedido.kilometros) { 182 if (notaPedido.kilometros) {
183 var cabeceraKilometros = { 183 var cabeceraKilometros = {
184 label: 'Kilometros:', 184 label: 'Kilometros:',
185 valor: notaPedido.kilometros 185 valor: notaPedido.kilometros
186 }; 186 };
187 cabeceras.push(cabeceraKilometros); 187 cabeceras.push(cabeceraKilometros);
188 } 188 }
189 cabeceras.push(cabeceraBomba); 189 cabeceras.push(cabeceraBomba);
190 } 190 }
191 191
192 delete notaPedido.id; 192 delete notaPedido.id;
193 $scope.remito = notaPedido; 193 $scope.remito = notaPedido;
194 $scope.remito.id = 0; 194 $scope.remito.id = 0;
195 $scope.remito.remitoPlazo = notaPedido.notaPedidoPlazo; 195 $scope.remito.remitoPlazo = notaPedido.notaPedidoPlazo;
196 196
197 for(var i = notaPedido.articulosNotaPedido.length - 1; i >= 0; i--) { 197 for(var i = notaPedido.articulosNotaPedido.length - 1; i >= 0; i--) {
198 notaPedido.articulosNotaPedido[i].id = 0; 198 notaPedido.articulosNotaPedido[i].id = 0;
199 } 199 }
200 200
201 $scope.remito.articulosRemito = notaPedido.articulosNotaPedido; 201 $scope.remito.articulosRemito = notaPedido.articulosNotaPedido;
202 remitoBusinessService.calcularArticulos($scope.remito.articulosRemito, 202 remitoBusinessService.calcularArticulos($scope.remito.articulosRemito,
203 notaPedido.cotizacion.VENDEDOR); 203 notaPedido.cotizacion.VENDEDOR);
204 204
205 if(notaPedido.idPrecioCondicion > 0) { 205 if(notaPedido.idPrecioCondicion > 0) {
206 $scope.idLista = notaPedido.precioCondicion.idListaPrecio; 206 $scope.idLista = notaPedido.precioCondicion.idListaPrecio;
207 }else { 207 }else {
208 $scope.idLista = -1; 208 $scope.idLista = -1;
209 } 209 }
210 210
211 enableObservaciones(notaPedido.observaciones ? true : false); 211 enableObservaciones(notaPedido.observaciones ? true : false);
212 addArrayCabecera(cabeceras); 212 addArrayCabecera(cabeceras);
213 213
214 }, function() { 214 }, function() {
215 // funcion ejecutada cuando se cancela el modal 215 // funcion ejecutada cuando se cancela el modal
216 } 216 }
217 ); 217 );
218 } 218 }
219 }; 219 };
220 220
221 $scope.seleccionarRemito = function() { 221 $scope.seleccionarRemito = function() {
222 var modalInstance = $uibModal.open( 222 var modalInstance = $uibModal.open(
223 { 223 {
224 ariaLabelledBy: 'Busqueda de Remito', 224 ariaLabelledBy: 'Busqueda de Remito',
225 templateUrl: 'foca-modal-remito.html', 225 templateUrl: 'foca-modal-remito.html',
226 controller: 'focaModalRemitoController', 226 controller: 'focaModalRemitoController',
227 size: 'lg', 227 size: 'lg',
228 resolve: {usadoPor: function() {return 'remito';}} 228 resolve: {usadoPor: function() {return 'remito';}}
229 } 229 }
230 ); 230 );
231 modalInstance.result.then( 231 modalInstance.result.then(
232 setearRemito, function() { 232 setearRemito, function() {
233 // funcion ejecutada cuando se cancela el modal 233 // funcion ejecutada cuando se cancela el modal
234 } 234 }
235 ); 235 );
236 }; 236 };
237 237
238 //validacion por domicilio y por plazo pago 238 //validacion por domicilio y por plazo pago
239 $scope.crearRemito = function() { 239 $scope.crearRemito = function() {
240 if (!$scope.remito.vendedor.NUM) { 240 if (!$scope.remito.vendedor.NUM) {
241 focaModalService.alert('Ingrese Vendedor'); 241 focaModalService.alert('Ingrese Vendedor');
242 return; 242 return;
243 } else if (!$scope.remito.cliente.COD) { 243 } else if (!$scope.remito.cliente.COD) {
244 focaModalService.alert('Ingrese Cliente'); 244 focaModalService.alert('Ingrese Cliente');
245 return; 245 return;
246 } else if (!$scope.remito.proveedor) { 246 } else if (!$scope.remito.proveedor) {
247 focaModalService.alert('Ingrese Proveedor'); 247 focaModalService.alert('Ingrese Proveedor');
248 return; 248 return;
249 } else if (!$scope.remito.cotizacion.moneda.id && 249 } else if (!$scope.remito.cotizacion.moneda.id &&
250 !$scope.remito.cotizacion.moneda.ID) 250 !$scope.remito.cotizacion.moneda.ID)
251 { 251 {
252 focaModalService.alert('Ingrese Moneda'); 252 focaModalService.alert('Ingrese Moneda');
253 return; 253 return;
254 } else if (!$scope.remito.cotizacion.ID) { 254 } else if (!$scope.remito.cotizacion.ID) {
255 focaModalService.alert('Ingrese Cotización'); 255 focaModalService.alert('Ingrese Cotización');
256 return; 256 return;
257 } else if ( 257 } else if (
258 $scope.remito.flete === undefined || $scope.remito.flete === null) 258 $scope.remito.flete === undefined || $scope.remito.flete === null)
259 { 259 {
260 focaModalService.alert('Ingrese Flete'); 260 focaModalService.alert('Ingrese Flete');
261 return; 261 return;
262 } else if ($scope.remito.articulosRemito.length === 0) { 262 } else if ($scope.remito.articulosRemito.length === 0) {
263 focaModalService.alert('Debe cargar al menos un articulo'); 263 focaModalService.alert('Debe cargar al menos un articulo');
264 return; 264 return;
265 } 265 }
266 focaBotoneraLateralService.startGuardar(); 266 focaBotoneraLateralService.startGuardar();
267 $scope.saveLoading = true; 267 $scope.saveLoading = true;
268 var save = { 268 var save = {
269 remito: { 269 remito: {
270 id: $scope.remito.id, 270 id: $scope.remito.id,
271 fechaRemito: $scope.now.toISOString().slice(0, 19).replace('T', ' '), 271 fechaRemito: $scope.now.toISOString().slice(0, 19).replace('T', ' '),
272 idCliente: $scope.remito.cliente.COD, 272 idCliente: $scope.remito.cliente.COD,
273 nombreCliente: $scope.remito.cliente.NOM, 273 nombreCliente: $scope.remito.cliente.NOM,
274 cuitCliente: $scope.remito.cliente.CUIT, 274 cuitCliente: $scope.remito.cliente.CUIT,
275 responsabilidadIvaCliente: 0,//TODO, 275 responsabilidadIvaCliente: 0,//TODO,
276 descuento: 0,//TODO, 276 descuento: 0,//TODO,
277 importeNeto: 0,//TODO 277 importeNeto: 0,//TODO
278 importeExento: 0,//TODO 278 importeExento: 0,//TODO
279 importeIva: 0,//TODO 279 importeIva: 0,//TODO
280 importeIvaServicios: 0,//TODO 280 importeIvaServicios: 0,//TODO
281 importeImpuestoInterno: 0,//TODO 281 importeImpuestoInterno: 0,//TODO
282 importeImpuestoInterno1: 0,//TODO 282 importeImpuestoInterno1: 0,//TODO
283 importeImpuestoInterno2: 0,//TODO 283 importeImpuestoInterno2: 0,//TODO
284 percepcion: 0,//TODO 284 percepcion: 0,//TODO
285 percepcionIva: 0,//TODO 285 percepcionIva: 0,//TODO
286 redondeo: 0,//TODO 286 redondeo: 0,//TODO
287 total: $scope.getTotal() * $scope.remito.cotizacion.VENDEDOR, 287 total: $scope.getTotal() * $scope.remito.cotizacion.VENDEDOR,
288 numeroNotaPedido: $scope.remito.numeroNotaPedido, 288 numeroNotaPedido: $scope.remito.numeroNotaPedido,
289 anulado: false, 289 anulado: false,
290 planilla: 0,//TODO 290 planilla: 0,//TODO
291 lugar: 0,//TODO 291 lugar: 0,//TODO
292 cuentaMadre: 0,// 292 cuentaMadre: 0,//
293 cuentaContable: 0,//TODO 293 cuentaContable: 0,//TODO
294 asiento: 0,//TODO 294 asiento: 0,//TODO
295 e_hd: '',//TODO 295 e_hd: '',//TODO
296 c_hd: '', 296 c_hd: '',
297 numeroLiquidoProducto: 0,//TODO 297 numeroLiquidoProducto: 0,//TODO
298 idVendedor: $scope.remito.idVendedor, 298 idVendedor: $scope.remito.idVendedor,
299 idProveedor: $scope.remito.idProveedor, 299 idProveedor: $scope.remito.idProveedor,
300 idDomicilio: $scope.remito.idDomicilio, 300 idDomicilio: $scope.remito.idDomicilio,
301 idCotizacion: $scope.remito.cotizacion.ID, 301 idCotizacion: $scope.remito.cotizacion.ID,
302 idPrecioCondicion: $scope.remito.idPrecioCondicion, 302 idPrecioCondicion: $scope.remito.idPrecioCondicion,
303 flete: $scope.remito.flete, 303 flete: $scope.remito.flete,
304 fob: $scope.remito.fob, 304 fob: $scope.remito.fob,
305 bomba: $scope.remito.bomba, 305 bomba: $scope.remito.bomba,
306 kilometros: $scope.remito.kilometros, 306 kilometros: $scope.remito.kilometros,
307 domicilioStamp: $scope.remito.domicilioStamp, 307 domicilioStamp: $scope.remito.domicilioStamp,
308 estado: 0,//TODO 308 estado: 0,//TODO
309 destinoVenta: 0,//TODO 309 destinoVenta: 0,//TODO
310 operacionTipo: 0//TODO 310 operacionTipo: 0//TODO
311 }, 311 },
312 notaPedido: $scope.notaPedido 312 notaPedido: $scope.notaPedido
313 }; 313 };
314 314
315 crearRemitoService.crearRemito(save).then( 315 crearRemitoService.crearRemito(save).then(
316 function(data) { 316 function(data) {
317 remitoBusinessService.addArticulos($scope.remito.articulosRemito, 317 remitoBusinessService.addArticulos($scope.remito.articulosRemito,
318 data.data.id, $scope.remito.cotizacion.COTIZACION); 318 data.data.id, $scope.remito.cotizacion.COTIZACION);
319 319
320 focaBotoneraLateralService.endGuardar(true); 320 focaBotoneraLateralService.endGuardar(true);
321 $scope.saveLoading = false; 321 $scope.saveLoading = false;
322 322
323 //TODO: updatear plazos 323 //TODO: updatear plazos
324 if($scope.remito.id === 0) { 324 if($scope.remito.id === 0) {
325 var plazos = $scope.remito.remitoPlazo; 325 var plazos = $scope.remito.remitoPlazo;
326 326
327 for(var j = 0; j < plazos.length; j++) { 327 for(var j = 0; j < plazos.length; j++) {
328 var json = { 328 var json = {
329 idRemito: $scope.remito.id, 329 idRemito: $scope.remito.id,
330 dias: plazos[j].dias 330 dias: plazos[j].dias
331 }; 331 };
332 crearRemitoService.crearPlazosParaRemito(json); 332 crearRemitoService.crearPlazosParaRemito(json);
333 } 333 }
334 } 334 }
335 335
336 $uibModal.open({ 336 $uibModal.open({
337 templateUrl: 'remito-comprobante.html', 337 templateUrl: 'remito-comprobante.html',
338 controller: 'focaRemitoComprobanteController', 338 controller: 'focaRemitoComprobanteController',
339 resolve: { 339 resolve: {
340 parametros: { 340 parametros: {
341 idRemito: data.data.id 341 idRemito: data.data.id
342 } 342 }
343 } 343 }
344 }); 344 });
345 345
346 init(); 346 init();
347 347
348 }, function(error) { 348 }, function(error) {
349 focaModalService.alert('Hubo un error al crear el remito'); 349 focaModalService.alert('Hubo un error al crear el remito');
350 focaBotoneraLateralService.endGuardar(); 350 focaBotoneraLateralService.endGuardar();
351 $scope.saveLoading = false; 351 $scope.saveLoading = false;
352 console.info(error); 352 console.info(error);
353 } 353 }
354 ); 354 );
355 }; 355 };
356 356
357 $scope.seleccionarProductos = function() { 357 $scope.seleccionarProductos = function() {
358 if($scope.idLista === undefined) { 358 if($scope.idLista === undefined) {
359 focaModalService.alert( 359 focaModalService.alert(
360 'Primero seleccione una lista de precio y condicion'); 360 'Primero seleccione una lista de precio y condicion');
361 return; 361 return;
362 } 362 }
363 var modalInstance = $uibModal.open( 363 var modalInstance = $uibModal.open(
364 { 364 {
365 ariaLabelledBy: 'Busqueda de Productos', 365 ariaLabelledBy: 'Busqueda de Productos',
366 templateUrl: 'modal-busqueda-productos.html', 366 templateUrl: 'modal-busqueda-productos.html',
367 controller: 'modalBusquedaProductosCtrl', 367 controller: 'modalBusquedaProductosCtrl',
368 resolve: { 368 resolve: {
369 parametroProducto: { 369 parametroProducto: {
370 idLista: $scope.idLista, 370 idLista: $scope.idLista,
371 cotizacion: $scope.remito.cotizacion.COTIZACION, 371 cotizacion: $scope.remito.cotizacion.COTIZACION,
372 simbolo: $scope.remito.cotizacion.moneda.simbolo 372 simbolo: $scope.remito.cotizacion.moneda.simbolo
373 } 373 }
374 }, 374 },
375 size: 'lg' 375 size: 'lg'
376 } 376 }
377 ); 377 );
378 modalInstance.result.then( 378 modalInstance.result.then(
379 function(producto) { 379 function(producto) {
380 var newArt = 380 var newArt =
381 { 381 {
382 id: 0, 382 id: 0,
383 codigo: producto.codigo, 383 codigo: producto.codigo,
384 sector: producto.sector, 384 sector: producto.sector,
385 sectorCodigo: producto.sector + '-' + producto.codigo, 385 sectorCodigo: producto.sector + '-' + producto.codigo,
386 descripcion: producto.descripcion, 386 descripcion: producto.descripcion,
387 item: $scope.remito.articulosRemito.length + 1, 387 item: $scope.remito.articulosRemito.length + 1,
388 nombre: producto.descripcion, 388 nombre: producto.descripcion,
389 precio: parseFloat(producto.precio.toFixed(4)), 389 precio: parseFloat(producto.precio.toFixed(4)),
390 costoUnitario: producto.costo, 390 costoUnitario: producto.costo,
391 editCantidad: false, 391 editCantidad: false,
392 editPrecio: false, 392 editPrecio: false,
393 rubro: producto.CodRub, 393 rubro: producto.CodRub,
394 exentoUnitario: producto.precio, 394 exentoUnitario: producto.precio,
395 ivaUnitario: producto.IMPIVA, 395 ivaUnitario: producto.IMPIVA,
396 impuestoInternoUnitario: producto.ImpInt, 396 impuestoInternoUnitario: producto.ImpInt,
397 impuestoInterno1Unitario: producto.ImpInt2, 397 impuestoInterno1Unitario: producto.ImpInt2,
398 impuestoInterno2Unitario: producto.ImpInt3, 398 impuestoInterno2Unitario: producto.ImpInt3,
399 precioLista: producto.precio, 399 precioLista: producto.precio,
400 combustible: 1, 400 combustible: 1,
401 facturado: 0 401 facturado: 0
402 }; 402 };
403 $scope.articuloACargar = newArt; 403 $scope.articuloACargar = newArt;
404 $scope.cargando = false; 404 $scope.cargando = false;
405 }, function() { 405 }, function() {
406 // funcion ejecutada cuando se cancela el modal 406 // funcion ejecutada cuando se cancela el modal
407 } 407 }
408 ); 408 );
409 }; 409 };
410 410
411 $scope.seleccionarPuntosDeDescarga = function() { 411 $scope.seleccionarPuntosDeDescarga = function() {
412 if(!$scope.remito.cliente.COD || !$scope.remito.domicilio.id) { 412 if(!$scope.remito.cliente.COD || !$scope.remito.domicilio.id) {
413 focaModalService.alert('Primero seleccione un cliente y un domicilio'); 413 focaModalService.alert('Primero seleccione un cliente y un domicilio');
414 return; 414 return;
415 }else { 415 }else {
416 var modalInstance = $uibModal.open( 416 var modalInstance = $uibModal.open(
417 { 417 {
418 ariaLabelledBy: 'Búsqueda de Puntos de descarga', 418 ariaLabelledBy: 'Búsqueda de Puntos de descarga',
419 templateUrl: 'modal-punto-descarga.html', 419 templateUrl: 'modal-punto-descarga.html',
420 controller: 'focaModalPuntoDescargaController', 420 controller: 'focaModalPuntoDescargaController',
421 size: 'lg', 421 size: 'lg',
422 resolve: { 422 resolve: {
423 filters: { 423 filters: {
424 idDomicilio: $scope.remito.domicilio.id, 424 idDomicilio: $scope.remito.domicilio.id,
425 idCliente: $scope.remito.cliente.COD, 425 idCliente: $scope.remito.cliente.COD,
426 articulos: $scope.remito.articulosRemito, 426 articulos: $scope.remito.articulosRemito,
427 puntosDescarga: $scope.remito.domicilio.puntosDescarga 427 puntosDescarga: $scope.remito.domicilio.puntosDescarga
428 } 428 }
429 } 429 }
430 } 430 }
431 ); 431 );
432 modalInstance.result.then( 432 modalInstance.result.then(
433 function(puntosDescarga) { 433 function(puntosDescarga) {
434 $scope.remito.puntosDescarga = puntosDescarga; 434 $scope.remito.puntosDescarga = puntosDescarga;
435 435
436 //AGREGO PUNTOS DE DESCARGA A CABECERA 436 //AGREGO PUNTOS DE DESCARGA A CABECERA
437 var puntosStamp = ''; 437 var puntosStamp = '';
438 puntosDescarga.forEach(function(punto, idx, arr) { 438 puntosDescarga.forEach(function(punto, idx, arr) {
439 puntosStamp += punto.descripcion; 439 puntosStamp += punto.descripcion;
440 if((idx + 1) !== arr.length) puntosStamp += ', '; 440 if((idx + 1) !== arr.length) puntosStamp += ', ';
441 }); 441 });
442 442
443 $scope.$broadcast('addCabecera', { 443 $scope.$broadcast('addCabecera', {
444 label: 'Puntos de descarga:', 444 label: 'Puntos de descarga:',
445 valor: puntosStamp 445 valor: puntosStamp
446 }); 446 });
447 }, function() { 447 }, function() {
448 $scope.abrirModalDomicilios($scope.cliente); 448 $scope.abrirModalDomicilios($scope.cliente);
449 } 449 }
450 ); 450 );
451 } 451 }
452 }; 452 };
453 453
454 $scope.seleccionarVendedor = function(callback, ocultarVendedor) { 454 $scope.seleccionarVendedor = function(callback, ocultarVendedor) {
455 if (ocultarVendedor) { 455 if (ocultarVendedor) {
456 callback(); 456 callback();
457 return; 457 return;
458 } 458 }
459 459
460 if(varlidarRemitoFacturado()) { 460 if(varlidarRemitoFacturado()) {
461 var parametrosModal = { 461 var parametrosModal = {
462 titulo: 'Búsqueda vendedores', 462 titulo: 'Búsqueda vendedores',
463 query: '/vendedor', 463 query: '/vendedor',
464 columnas: [ 464 columnas: [
465 { 465 {
466 propiedad: 'NUM', 466 propiedad: 'NUM',
467 nombre: 'Código', 467 nombre: 'Código',
468 filtro: { 468 filtro: {
469 nombre: 'rellenarDigitos', 469 nombre: 'rellenarDigitos',
470 parametro: 3 470 parametro: 3
471 } 471 }
472 }, 472 },
473 { 473 {
474 propiedad: 'NOM', 474 propiedad: 'NOM',
475 nombre: 'Nombre' 475 nombre: 'Nombre'
476 } 476 }
477 ], 477 ],
478 size: 'md' 478 size: 'md'
479 }; 479 };
480 focaModalService.modal(parametrosModal).then( 480 focaModalService.modal(parametrosModal).then(
481 function(vendedor) { 481 function(vendedor) {
482 $scope.$broadcast('addCabecera',{ 482 $scope.$broadcast('addCabecera',{
483 label: 'Vendedor:', 483 label: 'Vendedor:',
484 valor: $filter('rellenarDigitos')(vendedor.NUM, 3) + ' - ' + 484 valor: $filter('rellenarDigitos')(vendedor.NUM, 3) + ' - ' +
485 vendedor.NOM 485 vendedor.NOM
486 }); 486 });
487 $scope.remito.idVendedor = vendedor.id; 487 $scope.remito.idVendedor = vendedor.id;
488 $scope.remito.vendedor = vendedor; 488 $scope.remito.vendedor = vendedor;
489 deleteCliente(); 489 deleteCliente();
490 callback(); 490 callback();
491 }, function() { 491 }, function() {
492 492
493 } 493 }
494 ); 494 );
495 } 495 }
496 }; 496 };
497 497
498 $scope.seleccionarCliente = function(ocultarVendedor) { 498 $scope.seleccionarCliente = function(ocultarVendedor) {
499 499
500 $scope.seleccionarVendedor(function() { 500 $scope.seleccionarVendedor(function() {
501 if (varlidarRemitoFacturado()) { 501 if (varlidarRemitoFacturado()) {
502 var modalInstance = $uibModal.open( 502 var modalInstance = $uibModal.open(
503 { 503 {
504 ariaLabelledBy: 'Busqueda de Cliente', 504 ariaLabelledBy: 'Busqueda de Cliente',
505 templateUrl: 'foca-busqueda-cliente-modal.html', 505 templateUrl: 'foca-busqueda-cliente-modal.html',
506 controller: 'focaBusquedaClienteModalController', 506 controller: 'focaBusquedaClienteModalController',
507 resolve: { 507 resolve: {
508 vendedor: function() { return $scope.remito.vendedor; }, 508 vendedor: function() { return $scope.remito.vendedor; },
509 cobrador: function() { return null; } 509 cobrador: function() { return null; }
510 }, 510 },
511 size: 'lg' 511 size: 'lg'
512 } 512 }
513 ); 513 );
514 modalInstance.result.then( 514 modalInstance.result.then(
515 function(cliente) { 515 function(cliente) {
516 $scope.abrirModalDomicilios(cliente); 516 $scope.abrirModalDomicilios(cliente);
517 $scope.cliente = cliente; 517 $scope.cliente = cliente;
518 }, function() { 518 }, function() {
519 $scope.seleccionarCliente(); 519 $scope.seleccionarCliente();
520 } 520 }
521 ); 521 );
522 } 522 }
523 }, ocultarVendedor); 523 }, ocultarVendedor);
524 }; 524 };
525 525
526 $scope.seleccionarProveedor = function(callback) { 526 $scope.seleccionarProveedor = function(callback) {
527 if(varlidarRemitoFacturado()) { 527 if(varlidarRemitoFacturado()) {
528 var parametrosModal = { 528 var parametrosModal = {
529 titulo: 'Búsqueda de Proveedor', 529 titulo: 'Búsqueda de Proveedor',
530 query: '/proveedor', 530 query: '/proveedor',
531 columnas: [ 531 columnas: [
532 { 532 {
533 nombre: 'Código', 533 nombre: 'Código',
534 propiedad: 'COD', 534 propiedad: 'COD',
535 filtro: { 535 filtro: {
536 nombre: 'rellenarDigitos', 536 nombre: 'rellenarDigitos',
537 parametro: 5 537 parametro: 5
538 } 538 }
539 }, 539 },
540 { 540 {
541 nombre: 'Nombre', 541 nombre: 'Nombre',
542 propiedad: 'NOM' 542 propiedad: 'NOM'
543 }, 543 },
544 { 544 {
545 nombre: 'CUIT', 545 nombre: 'CUIT',
546 propiedad: 'CUIT' 546 propiedad: 'CUIT'
547 } 547 }
548 ], 548 ],
549 tipo: 'POST', 549 tipo: 'POST',
550 json: {razonCuitCod: ''} 550 json: {razonCuitCod: ''}
551 }; 551 };
552 focaModalService.modal(parametrosModal).then( 552 focaModalService.modal(parametrosModal).then(
553 function(proveedor) { 553 function(proveedor) {
554 $scope.remito.proveedor = proveedor; 554 $scope.remito.proveedor = proveedor;
555 $scope.remito.idProveedor = proveedor.COD; 555 $scope.remito.idProveedor = proveedor.COD;
556 556
557 $scope.$broadcast('addCabecera',{ 557 $scope.$broadcast('addCabecera',{
558 label: 'Proveedor:', 558 label: 'Proveedor:',
559 valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + 559 valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' +
560 proveedor.NOM 560 proveedor.NOM
561 }); 561 });
562 callback(); 562 callback();
563 }, function() { } 563 }, function() { }
564 ); 564 );
565 } 565 }
566 }; 566 };
567 567
568 $scope.abrirModalDomicilios = function(cliente) { 568 $scope.abrirModalDomicilios = function(cliente) {
569 var modalInstanceDomicilio = $uibModal.open( 569 var modalInstanceDomicilio = $uibModal.open(
570 { 570 {
571 ariaLabelledBy: 'Busqueda de Domicilios', 571 ariaLabelledBy: 'Busqueda de Domicilios',
572 templateUrl: 'modal-domicilio.html', 572 templateUrl: 'modal-domicilio.html',
573 controller: 'focaModalDomicilioController', 573 controller: 'focaModalDomicilioController',
574 size: 'lg', 574 size: 'lg',
575 resolve: { 575 resolve: {
576 idCliente: function() { return cliente.cod; }, 576 idCliente: function() { return cliente.cod; },
577 esNuevo: function() { return cliente.esNuevo; } 577 esNuevo: function() { return cliente.esNuevo; }
578 } 578 }
579 } 579 }
580 ); 580 );
581 modalInstanceDomicilio.result.then( 581 modalInstanceDomicilio.result.then(
582 function(domicilio) { 582 function(domicilio) {
583 $scope.remito.domicilio = domicilio; 583 $scope.remito.domicilio = domicilio;
584 $scope.remito.cliente = { 584 $scope.remito.cliente = {
585 COD: cliente.cod, 585 COD: cliente.cod,
586 CUIT: cliente.cuit, 586 CUIT: cliente.cuit,
587 NOM: cliente.nom, 587 NOM: cliente.nom,
588 MAIL: cliente.mail, 588 MAIL: cliente.mail,
589 MOD: cliente.mod 589 MOD: cliente.mod
590 }; 590 };
591 591
592 592
593 var domicilioStamp = 593 var domicilioStamp =
594 domicilio.Calle + ' ' + domicilio.Numero + ', ' + 594 domicilio.Calle + ' ' + domicilio.Numero + ', ' +
595 domicilio.Localidad + ', ' + domicilio.Provincia; 595 domicilio.Localidad + ', ' + domicilio.Provincia;
596 $scope.remito.domicilioStamp = domicilioStamp; 596 $scope.remito.domicilioStamp = domicilioStamp;
597 597
598 $scope.$broadcast('addCabecera',{ 598 $scope.$broadcast('addCabecera',{
599 label: 'Cliente:', 599 label: 'Cliente:',
600 valor: $filter('rellenarDigitos')(cliente.cod, 3) + ' - ' + cliente.nom 600 valor: $filter('rellenarDigitos')(cliente.cod, 3) + ' - ' + cliente.nom
601 }); 601 });
602 $scope.$broadcast('addCabecera',{ 602 $scope.$broadcast('addCabecera',{
603 label: 'Domicilio:', 603 label: 'Domicilio:',
604 valor: domicilioStamp 604 valor: domicilioStamp
605 }); 605 });
606 606
607 if(domicilio.verPuntos) { 607 if(domicilio.verPuntos) {
608 delete $scope.remito.domicilio.verPuntos; 608 delete $scope.remito.domicilio.verPuntos;
609 $scope.seleccionarPuntosDeDescarga(); 609 $scope.seleccionarPuntosDeDescarga();
610 }else { 610 }else {
611 crearRemitoService 611 crearRemitoService
612 .getPuntosDescargaByClienDom(domicilio.id, cliente.cod) 612 .getPuntosDescargaByClienDom(domicilio.id, cliente.cod)
613 .then(function(res) { 613 .then(function(res) {
614 if(res.data.length) $scope.seleccionarPuntosDeDescarga(); 614 if(res.data.length) $scope.seleccionarPuntosDeDescarga();
615 }); 615 });
616 } 616 }
617 }, function() { 617 }, function() {
618 $scope.seleccionarCliente(true); 618 $scope.seleccionarCliente(true);
619 return; 619 return;
620 } 620 }
621 ); 621 );
622 }; 622 };
623 623
624 $scope.getTotal = function() { 624 $scope.getTotal = function() {
625 var total = 0; 625 var total = 0;
626 var arrayTempArticulos = $scope.remito.articulosRemito; 626 var arrayTempArticulos = $scope.remito.articulosRemito;
627 for(var i = 0; i < arrayTempArticulos.length; i++) { 627 for(var i = 0; i < arrayTempArticulos.length; i++) {
628 total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; 628 total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad;
629 } 629 }
630 return parseFloat(total.toFixed(2)); 630 return parseFloat(total.toFixed(2));
631 }; 631 };
632 632
633 $scope.getSubTotal = function() { 633 $scope.getSubTotal = function() {
634 if($scope.articuloACargar) { 634 if($scope.articuloACargar) {
635 return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; 635 return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad;
636 } 636 }
637 }; 637 };
638 638
639 $scope.seleccionarPreciosYCondiciones = function() { 639 $scope.seleccionarPreciosYCondiciones = function() {
640 if (!$scope.remito.cliente.COD) { 640 if (!$scope.remito.cliente.COD) {
641 focaModalService.alert('Primero seleccione un cliente'); 641 focaModalService.alert('Primero seleccione un cliente');
642 return; 642 return;
643 } 643 }
644 if(varlidarRemitoFacturado()) { 644 if(varlidarRemitoFacturado()) {
645 var modalInstance = $uibModal.open( 645 var modalInstance = $uibModal.open(
646 { 646 {
647 ariaLabelledBy: 'Busqueda de Precio Condición', 647 ariaLabelledBy: 'Busqueda de Precio Condición',
648 templateUrl: 'modal-precio-condicion.html', 648 templateUrl: 'modal-precio-condicion.html',
649 controller: 'focaModalPrecioCondicionController', 649 controller: 'focaModalPrecioCondicionController',
650 size: 'lg', 650 size: 'lg',
651 resolve: { 651 resolve: {
652 idListaPrecio: function() { 652 idListaPrecio: function() {
653 return $scope.remito.cliente.MOD || null; 653 return $scope.remito.cliente.MOD || null;
654 } 654 }
655 } 655 }
656 } 656 }
657 ); 657 );
658 modalInstance.result.then( 658 modalInstance.result.then(
659 function(precioCondicion) { 659 function(precioCondicion) {
660 var cabecera = ''; 660 var cabecera = '';
661 var plazosConcat = ''; 661 var plazosConcat = '';
662 if(!Array.isArray(precioCondicion)) { 662 if(!Array.isArray(precioCondicion)) {
663 $scope.remito.idPrecioCondicion = precioCondicion.id; 663 $scope.remito.idPrecioCondicion = precioCondicion.id;
664 $scope.remito.remitoPlazo = precioCondicion.plazoPago; 664 $scope.remito.remitoPlazo = precioCondicion.plazoPago;
665 $scope.idLista = precioCondicion.idListaPrecio; 665 $scope.idLista = precioCondicion.idListaPrecio;
666 for(var i = 0; i < precioCondicion.plazoPago.length; i++) { 666 for(var i = 0; i < precioCondicion.plazoPago.length; i++) {
667 plazosConcat += precioCondicion.plazoPago[i].dias + ' '; 667 plazosConcat += precioCondicion.plazoPago[i].dias + ' ';
668 } 668 }
669 cabecera = $filter('rellenarDigitos')(precioCondicion.id, 4) + 669 cabecera = $filter('rellenarDigitos')(precioCondicion.id, 4) +
670 ' - ' + precioCondicion.nombre + ' ' + plazosConcat.trim(); 670 ' - ' + precioCondicion.nombre + ' ' + plazosConcat.trim();
671 }else { //Cuando se ingresan los plazos manualmente 671 }else { //Cuando se ingresan los plazos manualmente
672 $scope.remito.idPrecioCondicion = 0; 672 $scope.remito.idPrecioCondicion = 0;
673 //-1, el modal productos busca todos los productos 673 //-1, el modal productos busca todos los productos
674 $scope.idLista = -1; 674 $scope.idLista = -1;
675 $scope.remito.remitoPlazo = precioCondicion; 675 $scope.remito.remitoPlazo = precioCondicion;
676 for(var j = 0; j < precioCondicion.length; j++) { 676 for(var j = 0; j < precioCondicion.length; j++) {
677 plazosConcat += precioCondicion[j].dias + ' '; 677 plazosConcat += precioCondicion[j].dias + ' ';
678 } 678 }
679 cabecera = 'Ingreso manual ' + plazosConcat.trim(); 679 cabecera = 'Ingreso manual ' + plazosConcat.trim();
680 } 680 }
681 $scope.remito.articulosRemito = []; 681 $scope.remito.articulosRemito = [];
682 $scope.$broadcast('addCabecera',{ 682 $scope.$broadcast('addCabecera',{
683 label: 'Precios y condiciones:', 683 label: 'Precios y condiciones:',
684 valor: cabecera 684 valor: cabecera
685 }); 685 });
686 686
687 $scope.remito.precioCondicion = precioCondicion; 687 $scope.remito.precioCondicion = precioCondicion;
688 }, function() { 688 }, function() {
689 689
690 } 690 }
691 ); 691 );
692 } 692 }
693 }; 693 };
694 694
695 $scope.seleccionarTransportista = function() { 695 $scope.seleccionarTransportista = function() {
696 $scope.seleccionarProveedor(function() { 696 $scope.seleccionarProveedor(function() {
697 if (varlidarRemitoFacturado()) { 697 if (varlidarRemitoFacturado()) {
698 var modalInstance = $uibModal.open( 698 var modalInstance = $uibModal.open(
699 { 699 {
700 ariaLabelledBy: 'Busqueda de Flete', 700 ariaLabelledBy: 'Busqueda de Flete',
701 templateUrl: 'modal-flete.html', 701 templateUrl: 'modal-flete.html',
702 controller: 'focaModalFleteController', 702 controller: 'focaModalFleteController',
703 size: 'lg', 703 size: 'lg',
704 resolve: { 704 resolve: {
705 parametrosFlete: 705 parametrosFlete:
706 function() { 706 function() {
707 return { 707 return {
708 flete: $scope.remito.flete ? '1' : 708 flete: $scope.remito.flete ? '1' :
709 ($scope.remito.fob ? 'FOB' : 709 ($scope.remito.fob ? 'FOB' :
710 ($scope.remito.flete === undefined ? 710 ($scope.remito.flete === undefined ?
711 null : '0')), 711 null : '0')),
712 bomba: $scope.remito.bomba ? '1' : 712 bomba: $scope.remito.bomba ? '1' :
713 ($scope.remito.bomba === undefined ? 713 ($scope.remito.bomba === undefined ?
714 null : '0'), 714 null : '0'),
715 kilometros: $scope.remito.kilometros 715 kilometros: $scope.remito.kilometros
716 }; 716 };
717 } 717 }
718 } 718 }
719 } 719 }
720 ); 720 );
721 modalInstance.result.then( 721 modalInstance.result.then(
722 function(datos) { 722 function(datos) {
723 $scope.remito.flete = datos.flete; 723 $scope.remito.flete = datos.flete;
724 $scope.remito.fob = datos.FOB; 724 $scope.remito.fob = datos.FOB;
725 $scope.remito.bomba = datos.bomba; 725 $scope.remito.bomba = datos.bomba;
726 $scope.remito.kilometros = datos.kilometros; 726 $scope.remito.kilometros = datos.kilometros;
727 727
728 $scope.$broadcast('addCabecera',{ 728 $scope.$broadcast('addCabecera',{
729 label: 'Flete:', 729 label: 'Flete:',
730 valor: datos.flete ? 'Si' : ($scope.remito.fob ? 'FOB' : 'No') 730 valor: datos.flete ? 'Si' : ($scope.remito.fob ? 'FOB' : 'No')
731 }); 731 });
732 if (datos.flete) { 732 if (datos.flete) {
733 $scope.$broadcast('addCabecera',{ 733 $scope.$broadcast('addCabecera',{
734 label: 'Bomba:', 734 label: 'Bomba:',
735 valor: datos.bomba ? 'Si' : 'No' 735 valor: datos.bomba ? 'Si' : 'No'
736 }); 736 });
737 $scope.$broadcast('addCabecera',{ 737 $scope.$broadcast('addCabecera',{
738 label: 'Kilometros:', 738 label: 'Kilometros:',
739 valor: datos.kilometros 739 valor: datos.kilometros
740 }); 740 });
741 } else { 741 } else {
742 $scope.$broadcast('removeCabecera', 'Bomba:'); 742 $scope.$broadcast('removeCabecera', 'Bomba:');
743 $scope.$broadcast('removeCabecera', 'Kilometros:'); 743 $scope.$broadcast('removeCabecera', 'Kilometros:');
744 $scope.remito.fob = false; 744 $scope.remito.fob = false;
745 $scope.remito.bomba = false; 745 $scope.remito.bomba = false;
746 $scope.remito.kilometros = null; 746 $scope.remito.kilometros = null;
747 } 747 }
748 }, function() { 748 }, function() {
749 $scope.seleccionarTransportista(); 749 $scope.seleccionarTransportista();
750 } 750 }
751 ); 751 );
752 } 752 }
753 }); 753 });
754 }; 754 };
755 755
756 $scope.seleccionarMoneda = function() { 756 $scope.seleccionarMoneda = function() {
757 if(varlidarRemitoFacturado()) { 757 if(varlidarRemitoFacturado()) {
758 var parametrosModal = { 758 var parametrosModal = {
759 titulo: 'Búsqueda de monedas', 759 titulo: 'Búsqueda de monedas',
760 query: '/moneda', 760 query: '/moneda',
761 columnas: [ 761 columnas: [
762 { 762 {
763 propiedad: 'DETALLE', 763 propiedad: 'DETALLE',
764 nombre: 'Nombre' 764 nombre: 'Nombre'
765 }, 765 },
766 { 766 {
767 propiedad: 'SIMBOLO', 767 propiedad: 'SIMBOLO',
768 nombre: 'Símbolo' 768 nombre: 'Símbolo'
769 } 769 }
770 ], 770 ],
771 size: 'md' 771 size: 'md'
772 }; 772 };
773 focaModalService.modal(parametrosModal).then( 773 focaModalService.modal(parametrosModal).then(
774 function(moneda) { 774 function(moneda) {
775 $scope.abrirModalCotizacion(moneda); 775 $scope.abrirModalCotizacion(moneda);
776 }, function() { 776 }, function() {
777 777
778 } 778 }
779 ); 779 );
780 } 780 }
781 }; 781 };
782 782
783 $scope.seleccionarObservaciones = function() { 783 $scope.seleccionarObservaciones = function() {
784 focaModalService 784 focaModalService
785 .prompt({ 785 .prompt({
786 titulo: 'Observaciones', 786 titulo: 'Observaciones',
787 value: $scope.remito.observaciones, 787 value: $scope.remito.observaciones,
788 textarea: true, 788 textarea: true,
789 readonly: true 789 readonly: true
790 }) 790 })
791 .then(function(observaciones) { 791 .then(function(observaciones) {
792 $scope.remito.observaciones = observaciones; 792 $scope.remito.observaciones = observaciones;
793 }); 793 });
794 }; 794 };
795 795
796 $scope.abrirModalCotizacion = function(moneda) { 796 $scope.abrirModalCotizacion = function(moneda) {
797 var modalInstance = $uibModal.open( 797 var modalInstance = $uibModal.open(
798 { 798 {
799 ariaLabelledBy: 'Busqueda de Cotización', 799 ariaLabelledBy: 'Busqueda de Cotización',
800 templateUrl: 'modal-cotizacion.html', 800 templateUrl: 'modal-cotizacion.html',
801 controller: 'focaModalCotizacionController', 801 controller: 'focaModalCotizacionController',
802 size: 'lg', 802 size: 'lg',
803 resolve: {idMoneda: function() {return moneda.ID;}} 803 resolve: {idMoneda: function() {return moneda.ID;}}
804 } 804 }
805 ); 805 );
806 modalInstance.result.then( 806 modalInstance.result.then(
807 function(cotizacion) { 807 function(cotizacion) {
808 var articulosTablaTemp = $scope.remito.articulosRemito; 808 var articulosTablaTemp = $scope.remito.articulosRemito;
809 for(var i = 0; i < articulosTablaTemp.length; i++) { 809 for(var i = 0; i < articulosTablaTemp.length; i++) {
810 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * 810 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio *
811 $scope.remito.cotizacion.COTIZACION; 811 $scope.remito.cotizacion.COTIZACION;
812 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / 812 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio /
813 cotizacion.COTIZACION; 813 cotizacion.COTIZACION;
814 } 814 }
815 $scope.remito.articulosRemito = articulosTablaTemp; 815 $scope.remito.articulosRemito = articulosTablaTemp;
816 $scope.remito.cotizacion.moneda = moneda; 816 $scope.remito.cotizacion.moneda = moneda;
817 $scope.remito.cotizacion = cotizacion; 817 $scope.remito.cotizacion = cotizacion;
818 if(moneda.DETALLE === 'PESOS ARGENTINOS') { 818 if(moneda.DETALLE === 'PESOS ARGENTINOS') {
819 $scope.$broadcast('removeCabecera', 'Moneda:'); 819 $scope.$broadcast('removeCabecera', 'Moneda:');
820 $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); 820 $scope.$broadcast('removeCabecera', 'Fecha cotizacion:');
821 $scope.$broadcast('removeCabecera', 'Cotizacion:'); 821 $scope.$broadcast('removeCabecera', 'Cotizacion:');
822 }else { 822 }else {
823 $scope.$broadcast('addCabecera',{ 823 $scope.$broadcast('addCabecera',{
824 label: 'Moneda:', 824 label: 'Moneda:',
825 valor: moneda.DETALLE 825 valor: moneda.DETALLE
826 }); 826 });
827 $scope.$broadcast('addCabecera',{ 827 $scope.$broadcast('addCabecera',{
828 label: 'Fecha cotizacion:', 828 label: 'Fecha cotizacion:',
829 valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') 829 valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy')
830 }); 830 });
831 $scope.$broadcast('addCabecera',{ 831 $scope.$broadcast('addCabecera',{
832 label: 'Cotizacion:', 832 label: 'Cotizacion:',
833 valor: $filter('number')(cotizacion.COTIZACION, '2') 833 valor: $filter('number')(cotizacion.COTIZACION, '2')
834 }); 834 });
835 } 835 }
836 }, function() { 836 }, function() {
837 837
838 } 838 }
839 ); 839 );
840 }; 840 };
841 841
842 $scope.agregarATabla = function(key) { 842 $scope.agregarATabla = function(key) {
843 if(key === 13) { 843 if(key === 13) {
844 if($scope.articuloACargar.cantidad === undefined || 844 if($scope.articuloACargar.cantidad === undefined ||
845 $scope.articuloACargar.cantidad === 0 || 845 $scope.articuloACargar.cantidad === 0 ||
846 $scope.articuloACargar.cantidad === null ) { 846 $scope.articuloACargar.cantidad === null ) {
847 focaModalService.alert('El valor debe ser al menos 1'); 847 focaModalService.alert('El valor debe ser al menos 1');
848 return; 848 return;
849 } 849 }
850 delete $scope.articuloACargar.sectorCodigo; 850 delete $scope.articuloACargar.sectorCodigo;
851 $scope.remito.articulosRemito.push($scope.articuloACargar); 851 $scope.remito.articulosRemito.push($scope.articuloACargar);
852 $scope.cargando = true; 852 $scope.cargando = true;
853 } 853 }
854 }; 854 };
855 855
856 $scope.quitarArticulo = function(key) { 856 $scope.quitarArticulo = function(key) {
857 $scope.remito.articulosRemito.splice(key, 1); 857 $scope.remito.articulosRemito.splice(key, 1);
858 }; 858 };
859 859
860 $scope.editarArticulo = function(key, articulo) { 860 $scope.editarArticulo = function(key, articulo) {
861 if(key === 13) { 861 if (key === 13) {
862 if(articulo.cantidad === null || articulo.cantidad === 0 || 862 if (!articulo.cantidad || !articulo.precio) {
863 articulo.cantidad === undefined) { 863 focaModalService.alert('Los valores deben ser al menos 1');
864 focaModalService.alert('El valor debe ser al menos 1'); 864 return;
865 return; 865 } else if (articulo.cantidad < 0 || articulo.precio < 0) {
866 } 866 focaModalService.alert('Los valores no pueden ser negativos');
867 articulo.editCantidad = false; 867 return;
868 articulo.editPrecio = false; 868 }
869 } 869 articulo.editCantidad = articulo.editPrecio = false;
870 }; 870 }
871 871 };
872 $scope.cambioEdit = function(articulo, propiedad) { 872
873 if(propiedad === 'cantidad') { 873 $scope.cambioEdit = function(articulo, propiedad) {
874 articulo.editCantidad = true; 874 if(propiedad === 'cantidad') {
875 }else if(propiedad === 'precio') { 875 articulo.editCantidad = true;
876 }else if(propiedad === 'precio') {
877 articulo.editPrecio = true;
876 articulo.editPrecio = true; 878 }
877 } 879 };
878 }; 880
879
880 $scope.resetFilter = function() { 881 $scope.resetFilter = function() {
881 $scope.articuloACargar = {}; 882 $scope.articuloACargar = {};
882 $scope.cargando = true; 883 $scope.cargando = true;
883 }; 884 };
884 //Recibe aviso si el teclado está en uso 885 //Recibe aviso si el teclado está en uso
885 $rootScope.$on('usarTeclado', function(event, data) { 886 $rootScope.$on('usarTeclado', function(event, data) {
886 if(data) { 887 if(data) {
887 $scope.mostrarTeclado = true; 888 $scope.mostrarTeclado = true;
888 return; 889 return;
889 } 890 }
890 $scope.mostrarTeclado = false; 891 $scope.mostrarTeclado = false;
891 }); 892 });
892 893
893 $scope.selectFocus = function($event) { 894 $scope.selectFocus = function($event) {
894 // Si el teclado esta en uso no selecciona el valor 895 // Si el teclado esta en uso no selecciona el valor
895 if($scope.mostrarTeclado) { 896 if($scope.mostrarTeclado) {
896 return; 897 return;
897 } 898 }
898 $event.target.select(); 899 $event.target.select();
899 }; 900 };
900 901
901 function addArrayCabecera(array) { 902 function addArrayCabecera(array) {
902 for(var i = 0; i < array.length; i++) { 903 for(var i = 0; i < array.length; i++) {
903 $scope.$broadcast('addCabecera',{ 904 $scope.$broadcast('addCabecera',{
904 label: array[i].label, 905 label: array[i].label,
905 valor: array[i].valor 906 valor: array[i].valor
906 }); 907 });
907 } 908 }
908 } 909 }
909 910
910 function rellenar(relleno, longitud) { 911 function rellenar(relleno, longitud) {
911 relleno = '' + relleno; 912 relleno = '' + relleno;
912 while (relleno.length < longitud) { 913 while (relleno.length < longitud) {
913 relleno = '0' + relleno; 914 relleno = '0' + relleno;
914 } 915 }
915 916
916 return relleno; 917 return relleno;
917 } 918 }
918 919
919 function varlidarRemitoFacturado() { 920 function varlidarRemitoFacturado() {
920 if($scope.remito.estado !== 5) { 921 if($scope.remito.estado !== 5) {
921 return true; 922 return true;
922 }else { 923 }else {
923 focaModalService.alert('No se puede editar un remito facturado'); 924 focaModalService.alert('No se puede editar un remito facturado');
924 return false(); 925 return false();
925 } 926 }
926 } 927 }
927 928
928 function salir() { 929 function salir() {
929 var confirmacion = false; 930 var confirmacion = false;
930 931
931 if (!angular.equals($scope.remito, $scope.inicial)) { 932 if (!angular.equals($scope.remito, $scope.inicial)) {
932 confirmacion = true; 933 confirmacion = true;
933 } 934 }
934 935
935 if (confirmacion) { 936 if (confirmacion) {
936 focaModalService.confirm( 937 focaModalService.confirm(
937 '¿Está seguro de que desea salir? Se perderán todos los datos cargados.' 938 '¿Está seguro de que desea salir? Se perderán todos los datos cargados.'
938 ).then(function(data) { 939 ).then(function(data) {
939 if (data) { 940 if (data) {
940 $location.path('/'); 941 $location.path('/');
941 } 942 }
942 }); 943 });
943 } else { 944 } else {
944 $location.path('/'); 945 $location.path('/');
945 } 946 }
946 } 947 }
947 948
948 function enableObservaciones(val) { 949 function enableObservaciones(val) {
949 var boton = $scope.botonera.filter(function(botonObs) { 950 var boton = $scope.botonera.filter(function(botonObs) {
950 return botonObs.label === 'Observaciones'; 951 return botonObs.label === 'Observaciones';
951 }); 952 });
952 953
953 boton[0].disable = !val; 954 boton[0].disable = !val;
954 } 955 }
955 956
956 function setearRemito(remito) { 957 function setearRemito(remito) {
957 //añado cabeceras 958 //añado cabeceras
958 $scope.$broadcast('removeCabecera', 'Moneda:'); 959 $scope.$broadcast('removeCabecera', 'Moneda:');
959 $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); 960 $scope.$broadcast('removeCabecera', 'Fecha cotizacion:');
960 $scope.$broadcast('removeCabecera', 'Cotizacion:'); 961 $scope.$broadcast('removeCabecera', 'Cotizacion:');
961 962
962 var cabeceras = []; 963 var cabeceras = [];
963 964
964 if (remito.cotizacion.ID) { 965 if (remito.cotizacion.ID) {
965 cabeceras.push({ 966 cabeceras.push({
966 label: 'Moneda:', 967 label: 'Moneda:',
967 valor: remito.cotizacion.moneda.DETALLE 968 valor: remito.cotizacion.moneda.DETALLE
968 }); 969 });
969 cabeceras.push({ 970 cabeceras.push({
970 label: 'Fecha cotizacion:', 971 label: 'Fecha cotizacion:',
971 valor: $filter('date')(remito.cotizacion.FECHA, 972 valor: $filter('date')(remito.cotizacion.FECHA,
972 'dd/MM/yyyy') 973 'dd/MM/yyyy')
973 }); 974 });
974 cabeceras.push({ 975 cabeceras.push({
975 label: 'Cotizacion:', 976 label: 'Cotizacion:',
976 valor: $filter('number')(remito.cotizacion.VENDEDOR, 977 valor: $filter('number')(remito.cotizacion.VENDEDOR,
977 '2') 978 '2')
978 }); 979 });
979 } 980 }
980 if (remito.cliente.COD) { 981 if (remito.cliente.COD) {
981 cabeceras.push({ 982 cabeceras.push({
982 label: 'Cliente:', 983 label: 'Cliente:',
983 valor: $filter('rellenarDigitos')(remito.cliente.COD, 3) + ' - ' + 984 valor: $filter('rellenarDigitos')(remito.cliente.COD, 3) + ' - ' +
984 remito.cliente.NOM 985 remito.cliente.NOM
985 }); 986 });
986 cabeceras.push({ 987 cabeceras.push({
987 label: 'Domicilio:', 988 label: 'Domicilio:',
988 valor: remito.domicilioStamp 989 valor: remito.domicilioStamp
989 }); 990 });
990 } 991 }
991 if (remito.vendedor.NUM) { 992 if (remito.vendedor.NUM) {
992 cabeceras.push({ 993 cabeceras.push({
993 label: 'Vendedor:', 994 label: 'Vendedor:',
994 valor: $filter('rellenarDigitos')(remito.vendedor.NUM, 3) + 995 valor: $filter('rellenarDigitos')(remito.vendedor.NUM, 3) +
995 ' - ' + remito.vendedor.NOM 996 ' - ' + remito.vendedor.NOM
996 }); 997 });
997 } 998 }
998 if (remito.proveedor.COD) { 999 if (remito.proveedor.COD) {
999 cabeceras.push({ 1000 cabeceras.push({
1000 label: 'Proveedor:', 1001 label: 'Proveedor:',
1001 valor: $filter('rellenarDigitos')(remito.proveedor.COD, 5) + 1002 valor: $filter('rellenarDigitos')(remito.proveedor.COD, 5) +
1002 ' - ' + remito.proveedor.NOM 1003 ' - ' + remito.proveedor.NOM
1003 }); 1004 });
1004 } 1005 }
1005 if (remito.flete !== undefined) { 1006 if (remito.flete !== undefined) {
1006 cabeceras.push({ 1007 cabeceras.push({
1007 label: 'Flete:', 1008 label: 'Flete:',
1008 valor: remito.fob === 1 ? 'FOB' : ( 1009 valor: remito.fob === 1 ? 'FOB' : (
1009 remito.flete === 1 ? 'Si' : 'No') 1010 remito.flete === 1 ? 'Si' : 'No')
1010 }); 1011 });
1011 } 1012 }
1012 if (remito.remitoPlazo) { 1013 if (remito.remitoPlazo) {
1013 cabeceras.push({ 1014 cabeceras.push({
1014 label: 'Precio condicion:', 1015 label: 'Precio condicion:',
1015 valor: valorPrecioCondicion() + ' ' + 1016 valor: valorPrecioCondicion() + ' ' +
1016 remitoBusinessService.plazoToString(remito.remitoPlazo) 1017 remitoBusinessService.plazoToString(remito.remitoPlazo)
1017 }); 1018 });
1018 } 1019 }
1019 1020
1020 function valorPrecioCondicion() { 1021 function valorPrecioCondicion() {
1021 if (remito.idPrecioCondicion > 0) { 1022 if (remito.idPrecioCondicion > 0) {
1022 return remito.precioCondicion.nombre; 1023 return remito.precioCondicion.nombre;
1023 } else { 1024 } else {
1024 return 'Ingreso Manual'; 1025 return 'Ingreso Manual';
1025 } 1026 }
1026 } 1027 }
1027 1028
1028 if (remito.flete === 1) { 1029 if (remito.flete === 1) {
1029 var cabeceraBomba = { 1030 var cabeceraBomba = {
1030 label: 'Bomba', 1031 label: 'Bomba',
1031 valor: remito.bomba === 1 ? 'Si' : 'No' 1032 valor: remito.bomba === 1 ? 'Si' : 'No'
1032 }; 1033 };
1033 if (remito.kilometros) { 1034 if (remito.kilometros) {
1034 var cabeceraKilometros = { 1035 var cabeceraKilometros = {
1035 label: 'Kilometros', 1036 label: 'Kilometros',
1036 valor: remito.kilometros 1037 valor: remito.kilometros
1037 }; 1038 };
1038 cabeceras.push(cabeceraKilometros); 1039 cabeceras.push(cabeceraKilometros);
1039 } 1040 }
1040 cabeceras.push(cabeceraBomba); 1041 cabeceras.push(cabeceraBomba);
1041 } 1042 }
1042 $scope.remito.articulosRemito = remito.articulosRemito; 1043 $scope.remito.articulosRemito = remito.articulosRemito;
1043 remitoBusinessService.calcularArticulos($scope.remito.articulosRemito, 1044 remitoBusinessService.calcularArticulos($scope.remito.articulosRemito,
1044 remito.cotizacion.VENDEDOR); 1045 remito.cotizacion.VENDEDOR);
1045 if (remito.idPrecioCondicion > 0) { 1046 if (remito.idPrecioCondicion > 0) {
1046 $scope.idLista = remito.precioCondicion.idListaPrecio; 1047 $scope.idLista = remito.precioCondicion.idListaPrecio;
1047 } else { 1048 } else {
1048 $scope.idLista = -1; 1049 $scope.idLista = -1;
1049 } 1050 }
1050 $scope.puntoVenta = rellenar(remito.sucursal, 4); 1051 $scope.puntoVenta = rellenar(remito.sucursal, 4);
1051 $scope.comprobante = rellenar(remito.numeroRemito, 8); 1052 $scope.comprobante = rellenar(remito.numeroRemito, 8);
1052 $scope.remito = remito; 1053 $scope.remito = remito;
1053 addArrayCabecera(cabeceras); 1054 addArrayCabecera(cabeceras);
1054 } 1055 }
1055 1056
1056 function getLSRemito() { 1057 function getLSRemito() {
1057 var remito = JSON.parse($localStorage.remito || null); 1058 var remito = JSON.parse($localStorage.remito || null);
1058 if (remito) { 1059 if (remito) {
1059 setearRemito(remito); 1060 setearRemito(remito);
1060 delete $localStorage.remito; 1061 delete $localStorage.remito;
1061 } 1062 }
1062 } 1063 }
1063 1064
1064 function deleteCliente() { 1065 function deleteCliente() {
1065 delete $scope.remito.domicilioStamp; 1066 delete $scope.remito.domicilioStamp;
1066 delete $scope.remito.puntosDescarga; 1067 delete $scope.remito.puntosDescarga;
1067 $scope.remito.domicilio = {dom: ''}; 1068 $scope.remito.domicilio = {dom: ''};
1068 $scope.remito.cliente = {}; 1069 $scope.remito.cliente = {};
1069 $scope.$broadcast('removeCabecera', 'Cliente:'); 1070 $scope.$broadcast('removeCabecera', 'Cliente:');
1070 $scope.$broadcast('removeCabecera', 'Domicilio:'); 1071 $scope.$broadcast('removeCabecera', 'Domicilio:');
1071 $scope.$broadcast('removeCabecera', 'Puntos de descarga:'); 1072 $scope.$broadcast('removeCabecera', 'Puntos de descarga:');
1072 } 1073 }
1073 } 1074 }
1074 ]); 1075 ]);
src/views/remito.html
1 <div class="crear-nota-remito foca-crear row"> 1 <div class="crear-nota-remito foca-crear row">
2 <foca-cabecera-facturador 2 <foca-cabecera-facturador
3 titulo="'Remito'" 3 titulo="'Remito'"
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="seleccionarRemito" 7 busqueda="seleccionarRemito"
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 p-1 botonera-secundaria px-5 py-2"> 12 <div class="row p-1 botonera-secundaria px-5 py-2">
13 <div class="col-12"> 13 <div class="col-12">
14 <foca-botonera-facturador botones="botonera" extra="4" 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 class="">#</th> 22 <th class="">#</th>
23 <th class="col">Código</th> 23 <th class="col">Código</th>
24 <th class="col-4">Descripción</th> 24 <th class="col-4">Descripción</th>
25 <th class="col text-right">Cantidad</th> 25 <th class="col text-right">Cantidad</th>
26 <th class="col text-right">Precio Unitario</th> 26 <th class="col text-right">Precio Unitario</th>
27 <th class="col text-right">SubTotal</th> 27 <th class="col text-right">SubTotal</th>
28 <th class="text-right"> 28 <th 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 remito.articulosRemito" 50 ng-repeat="(key, articulo) in remito.articulosRemito"
51 ng-show="show || key == (remito.articulosRemito.length - 1)" 51 ng-show="show || key == (remito.articulosRemito.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 foca-focus="articulo.editCantidad" 70 foca-focus="articulo.editCantidad"
71 ng-keypress="editarArticulo($event.keyCode, articulo)" 71 ng-keypress="editarArticulo($event.keyCode, articulo)"
72 ng-focus="selectFocus($event)" 72 ng-focus="selectFocus($event)"
73 teclado-virtual 73 teclado-virtual
74 > 74 >
75 <i 75 <i
76 class="selectable" 76 class="selectable"
77 ng-click="cambioEdit(articulo, 'cantidad')" 77 ng-click="cambioEdit(articulo, 'cantidad')"
78 ng-hide="articulo.editCantidad" 78 ng-hide="articulo.editCantidad"
79 ng-bind="articulo.cantidad"> 79 ng-bind="articulo.cantidad">
80 </i> 80 </i>
81 </td> 81 </td>
82 <td class="col text-right"> 82 <td class="col text-right">
83 <input 83 <input
84 ng-show="articulo.editPrecio" 84 ng-show="articulo.editPrecio"
85 ng-model="articulo.precio" 85 ng-model="articulo.precio"
86 class="form-control" 86 class="form-control"
87 foca-tipo-input 87 foca-tipo-input
88 min="1" 88 min="1"
89 step="0.0001" 89 step="0.0001"
90 foca-focus="articulo.editPrecio" 90 foca-focus="articulo.editPrecio"
91 ng-keypress="editarArticulo($event.keyCode, articulo)" 91 ng-keypress="editarArticulo($event.keyCode, articulo)"
92 ng-focus="selectFocus($event)" 92 ng-focus="selectFocus($event)"
93 teclado-virtual 93 teclado-virtual
94 > 94 >
95 <i 95 <i
96 class="selectable" 96 class="selectable"
97 ng-click="cambioEdit(articulo, 'precio')" 97 ng-click="cambioEdit(articulo, 'precio')"
98 ng-hide="articulo.editPrecio" 98 ng-hide="articulo.editPrecio"
99 ng-bind="articulo.precio | number: 4"> 99 ng-bind="articulo.precio | number: 4">
100 </i> 100 </i>
101 </td> 101 </td>
102 <td 102 <td
103 class="col text-right" 103 class="col text-right"
104 ng-bind="(articulo.precio * articulo.cantidad) | number: 2"> 104 ng-bind="(articulo.precio * articulo.cantidad) | number: 2">
105 </td> 105 </td>
106 <td class="text-center"> 106 <td class="text-center">
107 <button 107 <button
108 class="btn btn-outline-light" 108 class="btn btn-outline-light"
109 ng-click="quitarArticulo(key)" 109 ng-click="quitarArticulo(key)"
110 ng-hide="articulo.editCantidad || articulo.editPrecio"
111 > 110 >
112 <i class="fa fa-trash"></i> 111 <i class="fa fa-trash"></i>
113 </button> 112 </button>
114 <button 113 <button
115 class="btn btn-outline-light" 114 class="btn btn-outline-light"
116 ng-click="editarArticulo(13, articulo)" 115 ng-click="editarArticulo(13, articulo)"
117 ng-show="articulo.editCantidad || articulo.editPrecio" 116 ng-show="articulo.editCantidad || articulo.editPrecio"
118 > 117 >
119 <i class="fa fa-save"></i> 118 <i class="fa fa-save"></i>
120 </button> 119 </button>
121 </td> 120 </td>
122 </tr> 121 </tr>
123 </tbody> 122 </tbody>
124 <tfoot> 123 <tfoot>
125 <tr ng-show="!cargando" class="d-flex"> 124 <tr ng-show="!cargando" class="d-flex">
126 <td 125 <td
127 class="align-middle" 126 class="align-middle"
128 ng-bind="remito.articulosRemito.length + 1" 127 ng-bind="remito.articulosRemito.length + 1"
129 ></td> 128 ></td>
130 <td class="col"> 129 <td class="col">
131 <input 130 <input
132 class="form-control" 131 class="form-control"
133 ng-model="articuloACargar.sectorCodigo" 132 ng-model="articuloACargar.sectorCodigo"
134 readonly 133 readonly
135 > 134 >
136 </td> 135 </td>
137 <td class="col-4 tabla-articulo-descripcion"> 136 <td class="col-4 tabla-articulo-descripcion">
138 <input 137 <input
139 class="form-control" 138 class="form-control"
140 ng-model="articuloACargar.descripcion" 139 ng-model="articuloACargar.descripcion"
141 readonly 140 readonly
142 > 141 >
143 </td> 142 </td>
144 <td class="col text-right"> 143 <td class="col text-right">
145 <input 144 <input
146 class="form-control" 145 class="form-control"
147 foca-tipo-input 146 foca-tipo-input
148 min="1" 147 min="1"
149 ng-model="articuloACargar.cantidad" 148 ng-model="articuloACargar.cantidad"
150 foca-focus="!cargando" 149 foca-focus="!cargando"
151 esc-key="resetFilter()" 150 esc-key="resetFilter()"
152 ng-keypress="agregarATabla($event.keyCode)" 151 ng-keypress="agregarATabla($event.keyCode)"
153 teclado-virtual 152 teclado-virtual
154 > 153 >
155 </td> 154 </td>
156 <td class="col text-right"> 155 <td class="col text-right">
157 <input 156 <input
158 class="form-control" 157 class="form-control"
159 ng-model="articuloACargar.precio" 158 ng-model="articuloACargar.precio"
160 ng-show="idLista != -1" 159 ng-show="idLista != -1"
161 ng-keypress="agregarATabla($event.keyCode)" 160 ng-keypress="agregarATabla($event.keyCode)"
162 > 161 >
163 <input 162 <input
164 class="form-control" 163 class="form-control"
165 foca-tipo-input 164 foca-tipo-input
166 step="0.0001" 165 step="0.0001"
167 ng-model="articuloACargar.precio" 166 ng-model="articuloACargar.precio"
168 esc-key="resetFilter()" 167 esc-key="resetFilter()"
169 ng-keypress="agregarATabla($event.keyCode)" 168 ng-keypress="agregarATabla($event.keyCode)"
170 ng-show="idLista == -1" 169 ng-show="idLista == -1"
171 teclado-virtual 170 teclado-virtual
172 > 171 >
173 </td> 172 </td>
174 <td class="col text-right"> 173 <td class="col text-right">
175 <input 174 <input
176 class="form-control" 175 class="form-control"
177 ng-value="getSubTotal() | number: 2" 176 ng-value="getSubTotal() | number: 2"
178 readonly 177 readonly
179 ></td> 178 ></td>
180 <td class="text-center align-middle"> 179 <td class="text-center align-middle">
181 <button 180 <button
182 class="btn btn-outline-light" 181 class="btn btn-outline-light"
183 ng-click="agregarATabla(13)" 182 ng-click="agregarATabla(13)"
184 > 183 >
185 <i class="fa fa-save"></i> 184 <i class="fa fa-save"></i>
186 </button> 185 </button>
187 </td> 186 </td>
188 </tr> 187 </tr>
189 188
190 <tr class="d-flex"> 189 <tr class="d-flex">
191 <td colspan="4" class="no-border-top"> 190 <td colspan="4" class="no-border-top">
192 <strong>Items:</strong> 191 <strong>Items:</strong>
193 <a ng-bind="remito.articulosRemito.length"></a> 192 <a ng-bind="remito.articulosRemito.length"></a>
194 </td> 193 </td>
195 <td class="text-right ml-auto table-celda-total no-border-top"> 194 <td class="text-right ml-auto table-celda-total no-border-top">
196 <h3>Total:</h3> 195 <h3>Total:</h3>
197 </td> 196 </td>
198 <td class="table-celda-total text-right no-border-top" colspan="1"> 197 <td class="table-celda-total text-right no-border-top" colspan="1">
199 <h3>{{getTotal() | currency: remito.moneda.SIMBOLO}}</h3> 198 <h3>{{getTotal() | currency: remito.moneda.SIMBOLO}}</h3>
200 </td> 199 </td>
201 <td class="text-right no-border-top"> 200 <td class="text-right no-border-top">
202 <button 201 <button
203 type="button" 202 type="button"
204 class="btn btn-default btn-sm" 203 class="btn btn-default btn-sm"
205 > 204 >
206 Totales 205 Totales
207 </button> 206 </button>
208 </td> 207 </td>
209 </tr> 208 </tr>
210 </tfoot> 209 </tfoot>
211 </table> 210 </table>
212 </div> 211 </div>
213 212
214 <!-- MOBILE --> 213 <!-- MOBILE -->
215 <div class="row d-sm-none"> 214 <div class="row d-sm-none">
216 <table class="table table-sm table-striped tabla-articulo margin-bottom-mobile"> 215 <table class="table table-sm table-striped tabla-articulo margin-bottom-mobile">
217 <thead> 216 <thead>
218 <tr class="d-flex"> 217 <tr class="d-flex">
219 <th class="">#</th> 218 <th class="">#</th>
220 <th class="col px-0"> 219 <th class="col px-0">
221 <div class="d-flex"> 220 <div class="d-flex">
222 <div class="col-4 px-1">Código</div> 221 <div class="col-4 px-1">Código</div>
223 <div class="col-8 px-1">Descripción</div> 222 <div class="col-8 px-1">Descripción</div>
224 </div> 223 </div>
225 <div class="d-flex"> 224 <div class="d-flex">
226 <div class="col-3 px-1">Cantidad</div> 225 <div class="col-3 px-1">Cantidad</div>
227 <div class="col px-1 text-right">P. Uni.</div> 226 <div class="col px-1 text-right">P. Uni.</div>
228 <div class="col px-1 text-right">Subtotal</div> 227 <div class="col px-1 text-right">Subtotal</div>
229 </div> 228 </div>
230 </th> 229 </th>
231 <th class="text-center tamaño-boton"> 230 <th class="text-center tamaño-boton">
232 &nbsp; 231 &nbsp;
233 </th> 232 </th>
234 </tr> 233 </tr>
235 </thead> 234 </thead>
236 <tbody> 235 <tbody>
237 <tr 236 <tr
238 ng-repeat="(key, articulo) in remito.articulosRemito" 237 ng-repeat="(key, articulo) in remito.articulosRemito"
239 ng-show="show || key == remito.articulosRemito.length - 1" 238 ng-show="show || key == remito.articulosRemito.length - 1"
240 > 239 >
241 <td class="w-100 align-middle d-flex p-0"> 240 <td class="w-100 align-middle d-flex p-0">
242 <div class="align-middle p-1"> 241 <div class="align-middle p-1">
243 <span ng-bind="key+1" class="align-middle"></span> 242 <span ng-bind="key+1" class="align-middle"></span>
244 </div> 243 </div>
245 <div class="col px-0"> 244 <div class="col px-0">
246 <div class="d-flex"> 245 <div class="d-flex">
247 <div class="col-4 px-1"> 246 <div class="col-4 px-1">
248 <span 247 <span
249 ng-bind="articulo.sector + '-' + articulo.codigo" 248 ng-bind="articulo.sector + '-' + articulo.codigo"
250 ></span> 249 ></span>
251 </div> 250 </div>
252 <div class="col-8 px-1"> 251 <div class="col-8 px-1">
253 <span 252 <span
254 ng-bind="'x' + articulo.cantidad" 253 ng-bind="'x' + articulo.cantidad"
255 ng-hide="articulo.editCantidad" 254 ng-hide="articulo.editCantidad"
256 ></span> 255 ></span>
257 <i 256 <i
258 class="fa fa-pencil text-white-50" 257 class="fa fa-pencil text-white-50"
259 aria-hidden="true" 258 aria-hidden="true"
260 ng-hide="articulo.editCantidad" 259 ng-hide="articulo.editCantidad"
261 ng-click="articulo.editCantidad = true" 260 ng-click="articulo.editCantidad = true"
262 ></i> 261 ></i>
263 <input 262 <input
264 ng-show="articulo.editCantidad" 263 ng-show="articulo.editCantidad"
265 ng-model="articulo.cantidad" 264 ng-model="articulo.cantidad"
266 class="form-control" 265 class="form-control"
267 foca-tipo-input 266 foca-tipo-input
268 min="1" 267 min="1"
269 step="0.001" 268 step="0.001"
270 foca-focus="articulo.editCantidad" 269 foca-focus="articulo.editCantidad"
271 ng-keypress="editarArticulo($event.keyCode, articulo)" 270 ng-keypress="editarArticulo($event.keyCode, articulo)"
272 ng-focus="selectFocus($event)" 271 ng-focus="selectFocus($event)"
273 > 272 >
274 </div> 273 </div>
275 </div> 274 </div>
276 <div class="d-flex"> 275 <div class="d-flex">
277 <div class="col-3 px-1"> 276 <div class="col-3 px-1">
278 <span ng-bind="'x' + articulo.cantidad"></span> 277 <span ng-bind="'x' + articulo.cantidad"></span>
279 </div> 278 </div>
280 <div class="col px-1 text-right"> 279 <div class="col px-1 text-right">
281 <span ng-bind="articulo.precio | currency: remito.moneda.SIMBOLO : 4"></span> 280 <span ng-bind="articulo.precio | currency: remito.moneda.SIMBOLO : 4"></span>
282 </div> 281 </div>
283 <div class="col px-1 text-right"> 282 <div class="col px-1 text-right">
284 <span 283 <span
285 ng-bind="(articulo.precio * articulo.cantidad) | currency: remito.moneda.SIMBOLO" 284 ng-bind="(articulo.precio * articulo.cantidad) | currency: remito.moneda.SIMBOLO"
286 > 285 >
287 </span> 286 </span>
288 </div> 287 </div>
289 </div> 288 </div>
290 </div> 289 </div>
291 <div class="align-middle p-1"> 290 <div class="align-middle p-1">
292 <button 291 <button
293 class="btn btn-outline-light" 292 class="btn btn-outline-light"
294 ng-click="quitarArticulo(key)" 293 ng-click="quitarArticulo(key)"
295 > 294 >
296 <i class="fa fa-trash"></i> 295 <i class="fa fa-trash"></i>
297 </button> 296 </button>
298 </div> 297 </div>
299 </td> 298 </td>
300 </tr> 299 </tr>
301 </tbody> 300 </tbody>
302 <tfoot> 301 <tfoot>
303 <!-- CARGANDO ITEM --> 302 <!-- CARGANDO ITEM -->
304 <tr ng-show="!cargando" class="d-flex"> 303 <tr ng-show="!cargando" class="d-flex">
305 <td 304 <td
306 class="align-middle p-1" 305 class="align-middle p-1"
307 ng-bind="remito.articulosRemito.length + 1" 306 ng-bind="remito.articulosRemito.length + 1"
308 ></td> 307 ></td>
309 <td class="col p-0"> 308 <td class="col p-0">
310 <div class="d-flex"> 309 <div class="d-flex">
311 <div class="col-4 px-1"> 310 <div class="col-4 px-1">
312 <span 311 <span
313 ng-bind="articuloACargar.sectorCodigo" 312 ng-bind="articuloACargar.sectorCodigo"
314 ></span> 313 ></span>
315 </div> 314 </div>
316 <div class="col-8 px-1"> 315 <div class="col-8 px-1">
317 <span ng-bind="articuloACargar.descripcion"></span> 316 <span ng-bind="articuloACargar.descripcion"></span>
318 </div> 317 </div>
319 </div> 318 </div>
320 <div class="d-flex"> 319 <div class="d-flex">
321 <div class="col-3 px-1 m-1"> 320 <div class="col-3 px-1 m-1">
322 <input 321 <input
323 class="form-control p-1" 322 class="form-control p-1"
324 foca-tipo-input 323 foca-tipo-input
325 min="1" 324 min="1"
326 ng-model="articuloACargar.cantidad" 325 ng-model="articuloACargar.cantidad"
327 foca-focus="!cargando" 326 foca-focus="!cargando"
328 ng-keypress="agregarATabla($event.keyCode)" 327 ng-keypress="agregarATabla($event.keyCode)"
329 style="height: auto; line-height: 1.1em" 328 style="height: auto; line-height: 1.1em"
330 > 329 >
331 </div> 330 </div>
332 <div class="col px-1 text-right"> 331 <div class="col px-1 text-right">
333 <span ng-bind="articuloACargar.precio | currency: remito.moneda.SIMBOLO : 4"></span> 332 <span ng-bind="articuloACargar.precio | currency: remito.moneda.SIMBOLO : 4"></span>
334 </div> 333 </div>
335 <div class="col px-1 text-right"> 334 <div class="col px-1 text-right">
336 <span 335 <span
337 ng-bind="getSubTotal() | currency: remito.moneda.SIMBOLO" 336 ng-bind="getSubTotal() | currency: remito.moneda.SIMBOLO"
338 > 337 >
339 </span> 338 </span>
340 </div> 339 </div>
341 </div> 340 </div>
342 </td> 341 </td>
343 <td class="text-center align-middle"> 342 <td class="text-center align-middle">
344 <button 343 <button
345 class="btn btn-outline-light" 344 class="btn btn-outline-light"
346 ng-click="agregarATabla(13)" 345 ng-click="agregarATabla(13)"
347 > 346 >
348 <i class="fa fa-save"></i> 347 <i class="fa fa-save"></i>
349 </button> 348 </button>
350 </td> 349 </td>
351 </tr> 350 </tr>
352 <!-- TOOGLE EXPANDIR --> 351 <!-- TOOGLE EXPANDIR -->
353 <tr> 352 <tr>
354 <td class="col"> 353 <td class="col">
355 <button 354 <button
356 class="btn btn-outline-light selectable w-100" 355 class="btn btn-outline-light selectable w-100"
357 ng-click="show = !show; masMenos()" 356 ng-click="show = !show; masMenos()"
358 ng-show="remito.articulosRemito.length > 0" 357 ng-show="remito.articulosRemito.length > 0"
359 > 358 >
360 <i 359 <i
361 class="fa fa-chevron-down" 360 class="fa fa-chevron-down"
362 ng-hide="show" 361 ng-hide="show"
363 aria-hidden="true" 362 aria-hidden="true"
364 > 363 >
365 </i> 364 </i>
366 <i 365 <i
367 class="fa fa-chevron-up" 366 class="fa fa-chevron-up"
368 ng-show="show" 367 ng-show="show"
369 aria-hidden="true"> 368 aria-hidden="true">
370 </i> 369 </i>
371 </button> 370 </button>
372 </td> 371 </td>
373 </tr> 372 </tr>
374 <!-- FOOTER --> 373 <!-- FOOTER -->
375 <tr class="d-flex"> 374 <tr class="d-flex">
376 <td class="align-middle no-border-top" colspan="2"> 375 <td class="align-middle no-border-top" colspan="2">
377 <strong>Cantidad Items:</strong> 376 <strong>Cantidad Items:</strong>
378 <a ng-bind="remito.articulosRemito.length"></a> 377 <a ng-bind="remito.articulosRemito.length"></a>
379 </td> 378 </td>
380 <td class="text-right ml-auto table-celda-total no-border-top"> 379 <td class="text-right ml-auto table-celda-total no-border-top">
381 <h3>Total:</h3> 380 <h3>Total:</h3>
382 </td> 381 </td>
383 <td class="table-celda-total text-right no-border-top"> 382 <td class="table-celda-total text-right no-border-top">
384 <h3>{{getTotal() | currency: remito.moneda.SIMBOLO}}</h3> 383 <h3>{{getTotal() | currency: remito.moneda.SIMBOLO}}</h3>
385 </td> 384 </td>
386 </tr> 385 </tr>
387 </tfoot> 386 </tfoot>
388 </table> 387 </table>
389 </div> 388 </div>
390 </div> 389 </div>
391 </div> 390 </div>
392 </div> 391 </div>
393 <div class="row d-md-none fixed-bottom"> 392 <div class="row d-md-none fixed-bottom">
394 <div class="w-100 bg-dark d-flex px-3 acciones-mobile"> 393 <div class="w-100 bg-dark d-flex px-3 acciones-mobile">
395 <span class="ml-3 text-muted" ng-click="salir()">Salir</span> 394 <span class="ml-3 text-muted" ng-click="salir()">Salir</span>
396 <span 395 <span
397 class="mr-3 ml-auto" 396 class="mr-3 ml-auto"
398 ng-class="saveLoading ? 'text-muted' : ''" 397 ng-class="saveLoading ? 'text-muted' : ''"
399 ng-click="crearRemito()" 398 ng-click="crearRemito()"
400 ladda="saveLoading" 399 ladda="saveLoading"
401 data-style="expand-left" 400 data-style="expand-left"
402 >Guardar</span> 401 >Guardar</span>
403 </div> 402 </div>
404 </div> 403 </div>
405 </div> 404 </div>
406 405