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