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