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