Commit 49538eae3a0dafdd966de1a3e9a677d11cb0f6db

Authored by Luigi
1 parent 9e2be9728b
Exists in master

Editar anterior

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