Commit 655c5e4ff822c19114ffc7920b91029553568109

Authored by Jose Pinto
1 parent 0656860a32
Exists in master

fuera boton proveedor y flete, agrego boton transportista

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