Commit 9e2be9728b6cbaeffa956843e775a03d5424a781

Authored by Luigi
1 parent 113f641f79
Exists in master

Save Remito - Editar campos precio / cantidad

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