Commit c4139b1786851496e20c7237bd3c4d3fb8f1d8d4

Authored by Eric Fernandez
Exists in master

Merge branch 'develop' into 'master'

Develop

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