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