Commit 78130a2d21b876559962fe6f2b6ccf7ecd2a8a2f
1 parent
d89e417321
Exists in
master
agrego resolve para modal de remito
Showing
1 changed file
with
3 additions
and
2 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', | 3 | '$scope', '$uibModal', '$location', '$filter', 'crearRemitoService', |
4 | 'focaModalService', 'remitoBusinessService', | 4 | 'focaModalService', 'remitoBusinessService', |
5 | function( | 5 | function( |
6 | $scope, $uibModal, $location, $filter, crearRemitoService, focaModalService, | 6 | $scope, $uibModal, $location, $filter, crearRemitoService, focaModalService, |
7 | remitoBusinessService | 7 | remitoBusinessService |
8 | ) { | 8 | ) { |
9 | $scope.botonera = [ | 9 | $scope.botonera = [ |
10 | {texto: 'Nota Pedido', accion: function() {$scope.seleccionarNotaPedido();}}, | 10 | {texto: 'Nota Pedido', accion: function() {$scope.seleccionarNotaPedido();}}, |
11 | {texto: 'Vendedor', accion: function() {$scope.seleccionarVendedor();}}, | 11 | {texto: 'Vendedor', accion: function() {$scope.seleccionarVendedor();}}, |
12 | {texto: 'Cliente', accion: function() {$scope.seleccionarCliente();}}, | 12 | {texto: 'Cliente', accion: function() {$scope.seleccionarCliente();}}, |
13 | {texto: 'Proveedor', accion: function() {$scope.seleccionarProveedor();}}, | 13 | {texto: 'Proveedor', accion: function() {$scope.seleccionarProveedor();}}, |
14 | {texto: 'Moneda', accion: function() {$scope.abrirModalMoneda();}}, | 14 | {texto: 'Moneda', accion: function() {$scope.abrirModalMoneda();}}, |
15 | { | 15 | { |
16 | texto: 'Precios y condiciones', | 16 | texto: 'Precios y condiciones', |
17 | accion: function() {$scope.abrirModalListaPrecio();}}, | 17 | accion: function() {$scope.abrirModalListaPrecio();}}, |
18 | {texto: 'Flete', accion: function() {$scope.abrirModalFlete();}}, | 18 | {texto: 'Flete', accion: function() {$scope.abrirModalFlete();}}, |
19 | {texto: '', accion: function() {}} | 19 | {texto: '', accion: function() {}} |
20 | ]; | 20 | ]; |
21 | $scope.datepickerAbierto = false; | 21 | $scope.datepickerAbierto = false; |
22 | 22 | ||
23 | $scope.show = false; | 23 | $scope.show = false; |
24 | $scope.cargando = true; | 24 | $scope.cargando = true; |
25 | $scope.dateOptions = { | 25 | $scope.dateOptions = { |
26 | maxDate: new Date(), | 26 | maxDate: new Date(), |
27 | minDate: new Date(2010, 0, 1) | 27 | minDate: new Date(2010, 0, 1) |
28 | }; | 28 | }; |
29 | 29 | ||
30 | $scope.remito = { | 30 | $scope.remito = { |
31 | id: 0, | 31 | id: 0, |
32 | vendedor: {}, | 32 | vendedor: {}, |
33 | cliente: {}, | 33 | cliente: {}, |
34 | proveedor: {}, | 34 | proveedor: {}, |
35 | domicilio: {dom: ''}, | 35 | domicilio: {dom: ''}, |
36 | moneda: {}, | 36 | moneda: {}, |
37 | cotizacion: {} | 37 | cotizacion: {} |
38 | }; | 38 | }; |
39 | 39 | ||
40 | $scope.notaPedido = { | 40 | $scope.notaPedido = { |
41 | id: 0 | 41 | id: 0 |
42 | }; | 42 | }; |
43 | var monedaPorDefecto; | 43 | var monedaPorDefecto; |
44 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' | 44 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' |
45 | crearRemitoService.getCotizacionByIdMoneda(1).then(function(res) { | 45 | crearRemitoService.getCotizacionByIdMoneda(1).then(function(res) { |
46 | monedaPorDefecto = res.data[0]; | 46 | monedaPorDefecto = res.data[0]; |
47 | addCabecera('Moneda:', monedaPorDefecto.DETALLE); | 47 | addCabecera('Moneda:', monedaPorDefecto.DETALLE); |
48 | addCabecera('Fecha cotizacion:', | 48 | addCabecera('Fecha cotizacion:', |
49 | new Date(monedaPorDefecto.cotizaciones[0].FECHA).toLocaleDateString()); | 49 | new Date(monedaPorDefecto.cotizaciones[0].FECHA).toLocaleDateString()); |
50 | addCabecera('Cotizacion:', monedaPorDefecto.cotizaciones[0].VENDEDOR); | 50 | addCabecera('Cotizacion:', monedaPorDefecto.cotizaciones[0].VENDEDOR); |
51 | $scope.remito.moneda = monedaPorDefecto; | 51 | $scope.remito.moneda = monedaPorDefecto; |
52 | $scope.remito.cotizacion = monedaPorDefecto.cotizaciones[0]; | 52 | $scope.remito.cotizacion = monedaPorDefecto.cotizaciones[0]; |
53 | }); | 53 | }); |
54 | 54 | ||
55 | $scope.cabecera = []; | 55 | $scope.cabecera = []; |
56 | $scope.showCabecera = true; | 56 | $scope.showCabecera = true; |
57 | 57 | ||
58 | $scope.now = new Date(); | 58 | $scope.now = new Date(); |
59 | $scope.puntoVenta = rellenar(0, 4); | 59 | $scope.puntoVenta = rellenar(0, 4); |
60 | $scope.comprobante = rellenar(0, 8); | 60 | $scope.comprobante = rellenar(0, 8); |
61 | 61 | ||
62 | $scope.articulosTabla = []; | 62 | $scope.articulosTabla = []; |
63 | $scope.idLista = undefined; | 63 | $scope.idLista = undefined; |
64 | //La pantalla solo se usa para cargar remitos | 64 | //La pantalla solo se usa para cargar remitos |
65 | //var remitoTemp = crearRemitoService.getRemito(); | 65 | //var remitoTemp = crearRemitoService.getRemito(); |
66 | 66 | ||
67 | crearRemitoService.getPrecioCondicion().then( | 67 | crearRemitoService.getPrecioCondicion().then( |
68 | function(res) { | 68 | function(res) { |
69 | $scope.precioCondiciones = res.data; | 69 | $scope.precioCondiciones = res.data; |
70 | } | 70 | } |
71 | ); | 71 | ); |
72 | 72 | ||
73 | crearRemitoService.getNumeroRemito().then( | 73 | crearRemitoService.getNumeroRemito().then( |
74 | function(res) { | 74 | function(res) { |
75 | $scope.puntoVenta = rellenar(res.data.sucursal, 4); | 75 | $scope.puntoVenta = rellenar(res.data.sucursal, 4); |
76 | $scope.comprobante = rellenar(res.data.numeroRemito, 8); | 76 | $scope.comprobante = rellenar(res.data.numeroRemito, 8); |
77 | }, | 77 | }, |
78 | function(err) { | 78 | function(err) { |
79 | focaModalService.alert('La terminal no esta configurada correctamente'); | 79 | focaModalService.alert('La terminal no esta configurada correctamente'); |
80 | console.info(err); | 80 | console.info(err); |
81 | } | 81 | } |
82 | ); | 82 | ); |
83 | 83 | ||
84 | $scope.seleccionarNotaPedido = function() { | 84 | $scope.seleccionarNotaPedido = function() { |
85 | var modalInstance = $uibModal.open( | 85 | var modalInstance = $uibModal.open( |
86 | { | 86 | { |
87 | ariaLabelledBy: 'Busqueda de Nota de Pedido', | 87 | ariaLabelledBy: 'Busqueda de Nota de Pedido', |
88 | templateUrl: 'foca-modal-nota-pedido.html', | 88 | templateUrl: 'foca-modal-nota-pedido.html', |
89 | controller: 'focaModalNotaPedidoController', | 89 | controller: 'focaModalNotaPedidoController', |
90 | size: 'lg', | 90 | size: 'lg', |
91 | resolve: {usadoPor: function() {return 'remito';}} | 91 | resolve: {usadoPor: function() {return 'remito';}} |
92 | } | 92 | } |
93 | ); | 93 | ); |
94 | modalInstance.result.then( | 94 | modalInstance.result.then( |
95 | function(notaPedido) { | 95 | function(notaPedido) { |
96 | //añado cabeceras | 96 | //añado cabeceras |
97 | $scope.notaPedido.id = notaPedido.id; | 97 | $scope.notaPedido.id = notaPedido.id; |
98 | removeCabecera('Moneda:'); | 98 | removeCabecera('Moneda:'); |
99 | removeCabecera('Fecha cotizacion:'); | 99 | removeCabecera('Fecha cotizacion:'); |
100 | removeCabecera('Cotizacion:'); | 100 | removeCabecera('Cotizacion:'); |
101 | var cabeceras = [ | 101 | var cabeceras = [ |
102 | { | 102 | { |
103 | label: 'Moneda:', | 103 | label: 'Moneda:', |
104 | valor: notaPedido.cotizacion[0].moneda[0].DETALLE | 104 | valor: notaPedido.cotizacion[0].moneda[0].DETALLE |
105 | }, | 105 | }, |
106 | { | 106 | { |
107 | label: 'Fecha cotizacion:', | 107 | label: 'Fecha cotizacion:', |
108 | valor: $filter('date')(notaPedido.cotizacion[0].FECHA, | 108 | valor: $filter('date')(notaPedido.cotizacion[0].FECHA, |
109 | 'dd/MM/yyyy') | 109 | 'dd/MM/yyyy') |
110 | }, | 110 | }, |
111 | { | 111 | { |
112 | label: 'Cotizacion:', | 112 | label: 'Cotizacion:', |
113 | valor: notaPedido.cotizacion[0].VENDEDOR | 113 | valor: notaPedido.cotizacion[0].VENDEDOR |
114 | }, | 114 | }, |
115 | { | 115 | { |
116 | label: 'Cliente:', | 116 | label: 'Cliente:', |
117 | valor: notaPedido.cliente[0].NOM | 117 | valor: notaPedido.cliente[0].NOM |
118 | }, | 118 | }, |
119 | { | 119 | { |
120 | label: 'Domicilio:', | 120 | label: 'Domicilio:', |
121 | valor: notaPedido.domicilioStamp | 121 | valor: notaPedido.domicilioStamp |
122 | }, | 122 | }, |
123 | { | 123 | { |
124 | label: 'Vendedor:', | 124 | label: 'Vendedor:', |
125 | valor: notaPedido.vendedor[0].NomVen | 125 | valor: notaPedido.vendedor[0].NomVen |
126 | }, | 126 | }, |
127 | { | 127 | { |
128 | label: 'Proveedor:', | 128 | label: 'Proveedor:', |
129 | valor: notaPedido.proveedor[0].NOM | 129 | valor: notaPedido.proveedor[0].NOM |
130 | }, | 130 | }, |
131 | { | 131 | { |
132 | label: 'Flete:', | 132 | label: 'Flete:', |
133 | valor: notaPedido.flete === 1 ? 'Si' : 'No' | 133 | valor: notaPedido.flete === 1 ? 'Si' : 'No' |
134 | }, | 134 | }, |
135 | { | 135 | { |
136 | label: 'FOB:', | 136 | label: 'FOB:', |
137 | valor: notaPedido.fob === 1 ? 'Si' : 'No' | 137 | valor: notaPedido.fob === 1 ? 'Si' : 'No' |
138 | }, | 138 | }, |
139 | { | 139 | { |
140 | label: 'Precio condicion:', | 140 | label: 'Precio condicion:', |
141 | valor: valorPrecioCondicion() | 141 | valor: valorPrecioCondicion() |
142 | } | 142 | } |
143 | ]; | 143 | ]; |
144 | //TODO: CUANDO MOSTRAR PLAZOS | 144 | //TODO: CUANDO MOSTRAR PLAZOS |
145 | function valorPrecioCondicion() { | 145 | function valorPrecioCondicion() { |
146 | if(notaPedido.idPrecioCondicion > 0) { | 146 | if(notaPedido.idPrecioCondicion > 0) { |
147 | return notaPedido.precioCondicion[0].nombre; | 147 | return notaPedido.precioCondicion[0].nombre; |
148 | } else { | 148 | } else { |
149 | return 'Ingreso Manual'; | 149 | return 'Ingreso Manual'; |
150 | } | 150 | } |
151 | } | 151 | } |
152 | 152 | ||
153 | if(notaPedido.flete === 1) { | 153 | if(notaPedido.flete === 1) { |
154 | var cabeceraBomba = { | 154 | var cabeceraBomba = { |
155 | label: 'Bomba', | 155 | label: 'Bomba', |
156 | valor: notaPedido.bomba === 1 ? 'Si' : 'No' | 156 | valor: notaPedido.bomba === 1 ? 'Si' : 'No' |
157 | }; | 157 | }; |
158 | if(notaPedido.kilometros) { | 158 | if(notaPedido.kilometros) { |
159 | var cabeceraKilometros = { | 159 | var cabeceraKilometros = { |
160 | label: 'Kilometros', | 160 | label: 'Kilometros', |
161 | valor: notaPedido.kilometros | 161 | valor: notaPedido.kilometros |
162 | }; | 162 | }; |
163 | cabeceras.push(cabeceraKilometros); | 163 | cabeceras.push(cabeceraKilometros); |
164 | } | 164 | } |
165 | cabeceras.push(cabeceraBomba); | 165 | cabeceras.push(cabeceraBomba); |
166 | } | 166 | } |
167 | $scope.articulosTabla = notaPedido.articulosNotaPedido; | 167 | $scope.articulosTabla = notaPedido.articulosNotaPedido; |
168 | remitoBusinessService.calcularArticulos($scope.articulosTabla, | 168 | remitoBusinessService.calcularArticulos($scope.articulosTabla, |
169 | notaPedido.cotizacion[0].VENDEDOR); | 169 | notaPedido.cotizacion[0].VENDEDOR); |
170 | if(notaPedido.precioCondicion.length > 0) { | 170 | if(notaPedido.precioCondicion.length > 0) { |
171 | $scope.idLista = notaPedido.precioCondicion[0].idListaPrecio; | 171 | $scope.idLista = notaPedido.precioCondicion[0].idListaPrecio; |
172 | } else { | 172 | } else { |
173 | $scope.idLista = -1; | 173 | $scope.idLista = -1; |
174 | } | 174 | } |
175 | delete notaPedido.id; | 175 | delete notaPedido.id; |
176 | $scope.remito = notaPedido; | 176 | $scope.remito = notaPedido; |
177 | $scope.remito.vendedor = notaPedido.vendedor[0]; | 177 | $scope.remito.vendedor = notaPedido.vendedor[0]; |
178 | $scope.remito.cliente = notaPedido.cliente[0]; | 178 | $scope.remito.cliente = notaPedido.cliente[0]; |
179 | $scope.remito.proveedor = notaPedido.proveedor[0]; | 179 | $scope.remito.proveedor = notaPedido.proveedor[0]; |
180 | $scope.remito.moneda = notaPedido.cotizacion[0].moneda[0]; | 180 | $scope.remito.moneda = notaPedido.cotizacion[0].moneda[0]; |
181 | $scope.remito.cotizacion = notaPedido.cotizacion[0]; | 181 | $scope.remito.cotizacion = notaPedido.cotizacion[0]; |
182 | addArrayCabecera(cabeceras); | 182 | addArrayCabecera(cabeceras); |
183 | 183 | ||
184 | }, function() { | 184 | }, function() { |
185 | // funcion ejecutada cuando se cancela el modal | 185 | // funcion ejecutada cuando se cancela el modal |
186 | } | 186 | } |
187 | ); | 187 | ); |
188 | }; | 188 | }; |
189 | 189 | ||
190 | $scope.seleccionarRemito = function() { | 190 | $scope.seleccionarRemito = function() { |
191 | var modalInstance = $uibModal.open( | 191 | var modalInstance = $uibModal.open( |
192 | { | 192 | { |
193 | ariaLabelledBy: 'Busqueda de Remito', | 193 | ariaLabelledBy: 'Busqueda de Remito', |
194 | templateUrl: 'foca-modal-remito.html', | 194 | templateUrl: 'foca-modal-remito.html', |
195 | controller: 'focaModalRemitoController', | 195 | controller: 'focaModalRemitoController', |
196 | size: 'lg' | 196 | size: 'lg', |
197 | resolve: {usadoPor: function() {return 'remito';}} | ||
197 | } | 198 | } |
198 | ); | 199 | ); |
199 | modalInstance.result.then( | 200 | modalInstance.result.then( |
200 | function(remito) { | 201 | function(remito) { |
201 | //añado cabeceras | 202 | //añado cabeceras |
202 | removeCabecera('Moneda:'); | 203 | removeCabecera('Moneda:'); |
203 | removeCabecera('Fecha cotizacion:'); | 204 | removeCabecera('Fecha cotizacion:'); |
204 | removeCabecera('Cotizacion:'); | 205 | removeCabecera('Cotizacion:'); |
205 | var cabeceras = [ | 206 | var cabeceras = [ |
206 | { | 207 | { |
207 | label: 'Moneda:', | 208 | label: 'Moneda:', |
208 | valor: remito.cotizacion[0].moneda[0].DETALLE | 209 | valor: remito.cotizacion[0].moneda[0].DETALLE |
209 | }, | 210 | }, |
210 | { | 211 | { |
211 | label: 'Fecha cotizacion:', | 212 | label: 'Fecha cotizacion:', |
212 | valor: $filter('date')(remito.cotizacion[0].FECHA, | 213 | valor: $filter('date')(remito.cotizacion[0].FECHA, |
213 | 'dd/MM/yyyy') | 214 | 'dd/MM/yyyy') |
214 | }, | 215 | }, |
215 | { | 216 | { |
216 | label: 'Cotizacion:', | 217 | label: 'Cotizacion:', |
217 | valor: remito.cotizacion[0].VENDEDOR | 218 | valor: remito.cotizacion[0].VENDEDOR |
218 | }, | 219 | }, |
219 | { | 220 | { |
220 | label: 'Cliente:', | 221 | label: 'Cliente:', |
221 | valor: remito.cliente[0].NOM | 222 | valor: remito.cliente[0].NOM |
222 | }, | 223 | }, |
223 | { | 224 | { |
224 | label: 'Domicilio:', | 225 | label: 'Domicilio:', |
225 | valor: remito.domicilioStamp | 226 | valor: remito.domicilioStamp |
226 | }, | 227 | }, |
227 | { | 228 | { |
228 | label: 'Vendedor:', | 229 | label: 'Vendedor:', |
229 | valor: remito.vendedor[0].NomVen | 230 | valor: remito.vendedor[0].NomVen |
230 | }, | 231 | }, |
231 | { | 232 | { |
232 | label: 'Proveedor:', | 233 | label: 'Proveedor:', |
233 | valor: remito.proveedor[0].NOM | 234 | valor: remito.proveedor[0].NOM |
234 | }, | 235 | }, |
235 | { | 236 | { |
236 | label: 'Flete:', | 237 | label: 'Flete:', |
237 | valor: remito.flete === 1 ? 'Si' : 'No' | 238 | valor: remito.flete === 1 ? 'Si' : 'No' |
238 | }, | 239 | }, |
239 | { | 240 | { |
240 | label: 'FOB:', | 241 | label: 'FOB:', |
241 | valor: remito.fob === 1 ? 'Si' : 'No' | 242 | valor: remito.fob === 1 ? 'Si' : 'No' |
242 | }, | 243 | }, |
243 | { | 244 | { |
244 | label: 'Precio condicion:', | 245 | label: 'Precio condicion:', |
245 | valor: valorPrecioCondicion() | 246 | valor: valorPrecioCondicion() |
246 | } | 247 | } |
247 | ]; | 248 | ]; |
248 | //TO DO CUANDO MOSTRAR PLAZOS | 249 | //TO DO CUANDO MOSTRAR PLAZOS |
249 | function valorPrecioCondicion() { | 250 | function valorPrecioCondicion() { |
250 | if(remito.idPrecioCondicion > 0) { | 251 | if(remito.idPrecioCondicion > 0) { |
251 | return remito.precioCondicion[0].nombre; | 252 | return remito.precioCondicion[0].nombre; |
252 | } else { | 253 | } else { |
253 | return 'Ingreso Manual'; | 254 | return 'Ingreso Manual'; |
254 | } | 255 | } |
255 | 256 | ||
256 | } | 257 | } |
257 | 258 | ||
258 | if(remito.flete === 1) { | 259 | if(remito.flete === 1) { |
259 | var cabeceraBomba = { | 260 | var cabeceraBomba = { |
260 | label: 'Bomba', | 261 | label: 'Bomba', |
261 | valor: remito.bomba === 1 ? 'Si' : 'No' | 262 | valor: remito.bomba === 1 ? 'Si' : 'No' |
262 | }; | 263 | }; |
263 | if(remito.kilometros) { | 264 | if(remito.kilometros) { |
264 | var cabeceraKilometros = { | 265 | var cabeceraKilometros = { |
265 | label: 'Kilometros', | 266 | label: 'Kilometros', |
266 | valor: remito.kilometros | 267 | valor: remito.kilometros |
267 | }; | 268 | }; |
268 | cabeceras.push(cabeceraKilometros); | 269 | cabeceras.push(cabeceraKilometros); |
269 | } | 270 | } |
270 | cabeceras.push(cabeceraBomba); | 271 | cabeceras.push(cabeceraBomba); |
271 | } | 272 | } |
272 | $scope.articulosTabla = remito.articulosRemito; | 273 | $scope.articulosTabla = remito.articulosRemito; |
273 | remitoBusinessService.calcularArticulos($scope.articulosTabla, | 274 | remitoBusinessService.calcularArticulos($scope.articulosTabla, |
274 | remito.cotizacion[0].VENDEDOR); | 275 | remito.cotizacion[0].VENDEDOR); |
275 | if(remito.precioCondicion.length > 0) { | 276 | if(remito.precioCondicion.length > 0) { |
276 | $scope.idLista = remito.precioCondicion[0].idListaPrecio; | 277 | $scope.idLista = remito.precioCondicion[0].idListaPrecio; |
277 | } else { | 278 | } else { |
278 | $scope.idLista = -1; | 279 | $scope.idLista = -1; |
279 | } | 280 | } |
280 | $scope.comprobante = rellenar(remito.numeroRemito, 8); | 281 | $scope.comprobante = rellenar(remito.numeroRemito, 8); |
281 | $scope.remito = remito; | 282 | $scope.remito = remito; |
282 | $scope.remito.vendedor = remito.vendedor[0]; | 283 | $scope.remito.vendedor = remito.vendedor[0]; |
283 | $scope.remito.cliente = remito.cliente[0]; | 284 | $scope.remito.cliente = remito.cliente[0]; |
284 | $scope.remito.proveedor = remito.proveedor[0]; | 285 | $scope.remito.proveedor = remito.proveedor[0]; |
285 | $scope.remito.moneda = remito.cotizacion[0].moneda[0]; | 286 | $scope.remito.moneda = remito.cotizacion[0].moneda[0]; |
286 | $scope.remito.cotizacion = remito.cotizacion[0]; | 287 | $scope.remito.cotizacion = remito.cotizacion[0]; |
287 | addArrayCabecera(cabeceras); | 288 | addArrayCabecera(cabeceras); |
288 | }, function() { | 289 | }, function() { |
289 | // funcion ejecutada cuando se cancela el modal | 290 | // funcion ejecutada cuando se cancela el modal |
290 | } | 291 | } |
291 | ); | 292 | ); |
292 | }; | 293 | }; |
293 | 294 | ||
294 | //La pantalla solo se usa para cargar remitos | 295 | //La pantalla solo se usa para cargar remitos |
295 | // if (remitoTemp !== undefined) { | 296 | // if (remitoTemp !== undefined) { |
296 | // remitoTemp.fechaCarga = new Date(remitoTemp.fechaCarga); | 297 | // remitoTemp.fechaCarga = new Date(remitoTemp.fechaCarga); |
297 | // $scope.remito = remitoTemp; | 298 | // $scope.remito = remitoTemp; |
298 | // $scope.remito.flete = ($scope.remito.flete).toString(); | 299 | // $scope.remito.flete = ($scope.remito.flete).toString(); |
299 | // $scope.remito.bomba = ($scope.remito.bomba).toString(); | 300 | // $scope.remito.bomba = ($scope.remito.bomba).toString(); |
300 | // $scope.idLista = $scope.remito.precioCondicion; | 301 | // $scope.idLista = $scope.remito.precioCondicion; |
301 | // crearRemitoService | 302 | // crearRemitoService |
302 | // .getArticulosByIdRemito($scope.remito.id).then( | 303 | // .getArticulosByIdRemito($scope.remito.id).then( |
303 | // function(res) { | 304 | // function(res) { |
304 | // $scope.articulosTabla = res.data; | 305 | // $scope.articulosTabla = res.data; |
305 | // } | 306 | // } |
306 | // ); | 307 | // ); |
307 | //TODO DOMICILIOS QUE SE CARGAN AL EDITAR REMITO | 308 | //TODO DOMICILIOS QUE SE CARGAN AL EDITAR REMITO |
308 | //(NO REQUERIDO EN ESTA VERSION) | 309 | //(NO REQUERIDO EN ESTA VERSION) |
309 | // crearRemitoService.getDomiciliosByIdRemito($scope.remito.id).then( | 310 | // crearRemitoService.getDomiciliosByIdRemito($scope.remito.id).then( |
310 | // function(res) { | 311 | // function(res) { |
311 | // $scope.remito.domicilio = res.data; | 312 | // $scope.remito.domicilio = res.data; |
312 | // } | 313 | // } |
313 | // ); | 314 | // ); |
314 | // } else { | 315 | // } else { |
315 | // $scope.remito.fechaCarga = new Date(); | 316 | // $scope.remito.fechaCarga = new Date(); |
316 | // $scope.remito.bomba = '0'; | 317 | // $scope.remito.bomba = '0'; |
317 | // $scope.remito.flete = '0'; | 318 | // $scope.remito.flete = '0'; |
318 | // $scope.idLista = undefined; | 319 | // $scope.idLista = undefined; |
319 | // } | 320 | // } |
320 | //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO | 321 | //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO |
321 | // $scope.addNewDom = function() { | 322 | // $scope.addNewDom = function() { |
322 | // $scope.remito.domicilio.push({ 'id': 0 }); | 323 | // $scope.remito.domicilio.push({ 'id': 0 }); |
323 | // }; | 324 | // }; |
324 | // $scope.removeNewChoice = function(choice) { | 325 | // $scope.removeNewChoice = function(choice) { |
325 | // if ($scope.remito.domicilio.length > 1) { | 326 | // if ($scope.remito.domicilio.length > 1) { |
326 | // $scope.remito.domicilio.splice($scope.remito.domicilio.findIndex( | 327 | // $scope.remito.domicilio.splice($scope.remito.domicilio.findIndex( |
327 | // function(c) { | 328 | // function(c) { |
328 | // return c.$$hashKey === choice.$$hashKey; | 329 | // return c.$$hashKey === choice.$$hashKey; |
329 | // } | 330 | // } |
330 | // ), 1); | 331 | // ), 1); |
331 | // } | 332 | // } |
332 | // }; | 333 | // }; |
333 | //validacion por domicilio y por plazo pago | 334 | //validacion por domicilio y por plazo pago |
334 | $scope.crearRemito = function() { | 335 | $scope.crearRemito = function() { |
335 | if(!$scope.remito.vendedor) { | 336 | if(!$scope.remito.vendedor) { |
336 | focaModalService.alert('Ingrese Vendedor'); | 337 | focaModalService.alert('Ingrese Vendedor'); |
337 | return; | 338 | return; |
338 | } else if(!$scope.remito.cliente) { | 339 | } else if(!$scope.remito.cliente) { |
339 | focaModalService.alert('Ingrese Cliente'); | 340 | focaModalService.alert('Ingrese Cliente'); |
340 | return; | 341 | return; |
341 | } else if(!$scope.remito.proveedor) { | 342 | } else if(!$scope.remito.proveedor) { |
342 | focaModalService.alert('Ingrese Proveedor'); | 343 | focaModalService.alert('Ingrese Proveedor'); |
343 | return; | 344 | return; |
344 | } else if(!$scope.remito.moneda.id && !$scope.remito.moneda.ID) { | 345 | } else if(!$scope.remito.moneda.id && !$scope.remito.moneda.ID) { |
345 | focaModalService.alert('Ingrese Moneda'); | 346 | focaModalService.alert('Ingrese Moneda'); |
346 | return; | 347 | return; |
347 | } else if(!$scope.remito.cotizacion.ID) { | 348 | } else if(!$scope.remito.cotizacion.ID) { |
348 | focaModalService.alert('Ingrese Cotización'); | 349 | focaModalService.alert('Ingrese Cotización'); |
349 | return; | 350 | return; |
350 | } else if( | 351 | } else if( |
351 | $scope.remito.flete === undefined || $scope.remito.flete === null) | 352 | $scope.remito.flete === undefined || $scope.remito.flete === null) |
352 | { | 353 | { |
353 | focaModalService.alert('Ingrese Flete'); | 354 | focaModalService.alert('Ingrese Flete'); |
354 | return; | 355 | return; |
355 | } else if($scope.articulosTabla.length === 0) { | 356 | } else if($scope.articulosTabla.length === 0) { |
356 | focaModalService.alert('Debe cargar al menos un articulo'); | 357 | focaModalService.alert('Debe cargar al menos un articulo'); |
357 | return; | 358 | return; |
358 | } | 359 | } |
359 | var date = new Date(); | 360 | var date = new Date(); |
360 | var save = { | 361 | var save = { |
361 | remito: { | 362 | remito: { |
362 | id: $scope.remito.id, | 363 | id: $scope.remito.id, |
363 | fechaRemito: | 364 | fechaRemito: |
364 | new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) | 365 | new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) |
365 | .toISOString().slice(0, 19).replace('T', ' '),//TODO$filter | 366 | .toISOString().slice(0, 19).replace('T', ' '),//TODO$filter |
366 | idCliente: $scope.remito.cliente.COD, | 367 | idCliente: $scope.remito.cliente.COD, |
367 | nombreCliente: $scope.remito.cliente.NOM, | 368 | nombreCliente: $scope.remito.cliente.NOM, |
368 | cuitCliente: $scope.remito.cliente.CUIT, | 369 | cuitCliente: $scope.remito.cliente.CUIT, |
369 | responsabilidadIvaCliente: 0,//TODO, | 370 | responsabilidadIvaCliente: 0,//TODO, |
370 | descuento: 0,//TODO, | 371 | descuento: 0,//TODO, |
371 | importeNeto: 0,//TODO | 372 | importeNeto: 0,//TODO |
372 | importeExento: 0,//TODO | 373 | importeExento: 0,//TODO |
373 | importeIva: 0,//TODO | 374 | importeIva: 0,//TODO |
374 | importeIvaServicios: 0,//TODO | 375 | importeIvaServicios: 0,//TODO |
375 | importeImpuestoInterno: 0,//TODO | 376 | importeImpuestoInterno: 0,//TODO |
376 | importeImpuestoInterno1: 0,//TODO | 377 | importeImpuestoInterno1: 0,//TODO |
377 | importeImpuestoInterno2: 0,//TODO | 378 | importeImpuestoInterno2: 0,//TODO |
378 | percepcion: 0,//TODO | 379 | percepcion: 0,//TODO |
379 | percepcionIva: 0,//TODO | 380 | percepcionIva: 0,//TODO |
380 | redondeo: 0,//TODO | 381 | redondeo: 0,//TODO |
381 | total: $scope.getTotal(), | 382 | total: $scope.getTotal(), |
382 | numeroNotaPedido: $scope.remito.numeroNotaPedido, | 383 | numeroNotaPedido: $scope.remito.numeroNotaPedido, |
383 | anulado: false, | 384 | anulado: false, |
384 | planilla: 0,//TODO | 385 | planilla: 0,//TODO |
385 | lugar: 0,//TODO | 386 | lugar: 0,//TODO |
386 | cuentaMadre: 0,// | 387 | cuentaMadre: 0,// |
387 | cuentaContable: 0,//TODO | 388 | cuentaContable: 0,//TODO |
388 | asiento: 0,//TODO | 389 | asiento: 0,//TODO |
389 | e_hd: '',//TODO | 390 | e_hd: '',//TODO |
390 | c_hd: '', | 391 | c_hd: '', |
391 | numeroLiquidoProducto: 0,//TODO | 392 | numeroLiquidoProducto: 0,//TODO |
392 | idVendedor: $scope.remito.idVendedor, | 393 | idVendedor: $scope.remito.idVendedor, |
393 | idProveedor: $scope.remito.idProveedor, | 394 | idProveedor: $scope.remito.idProveedor, |
394 | idDomicilio: 0,//TODO | 395 | idDomicilio: 0,//TODO |
395 | idCotizacion: $scope.remito.cotizacion.ID, | 396 | idCotizacion: $scope.remito.cotizacion.ID, |
396 | idPrecioCondicion: $scope.remito.idPrecioCondicion, | 397 | idPrecioCondicion: $scope.remito.idPrecioCondicion, |
397 | flete: $scope.remito.flete, | 398 | flete: $scope.remito.flete, |
398 | fob: $scope.remito.fob, | 399 | fob: $scope.remito.fob, |
399 | bomba: $scope.remito.bomba, | 400 | bomba: $scope.remito.bomba, |
400 | kilometros: $scope.remito.kilometros, | 401 | kilometros: $scope.remito.kilometros, |
401 | domicilioStamp: $scope.remito.domicilioStamp, | 402 | domicilioStamp: $scope.remito.domicilioStamp, |
402 | estado: 0,//TODO | 403 | estado: 0,//TODO |
403 | destinoVenta: 0,//TODO | 404 | destinoVenta: 0,//TODO |
404 | operacionTipo: 0//TODO | 405 | operacionTipo: 0//TODO |
405 | }, | 406 | }, |
406 | notaPedido: $scope.notaPedido | 407 | notaPedido: $scope.notaPedido |
407 | }; | 408 | }; |
408 | crearRemitoService.crearRemito(save).then( | 409 | crearRemitoService.crearRemito(save).then( |
409 | function(data) { | 410 | function(data) { |
410 | remitoBusinessService.addArticulos($scope.articulosTabla, | 411 | remitoBusinessService.addArticulos($scope.articulosTabla, |
411 | data.data.id, $scope.remito.cotizacion.COTIZACION); | 412 | data.data.id, $scope.remito.cotizacion.COTIZACION); |
412 | 413 | ||
413 | focaModalService.alert('Nota remito creada'); | 414 | focaModalService.alert('Remito creado'); |
414 | $scope.cabecera = []; | 415 | $scope.cabecera = []; |
415 | addCabecera('Moneda:', $scope.remito.moneda.DETALLE); | 416 | addCabecera('Moneda:', $scope.remito.moneda.DETALLE); |
416 | addCabecera( | 417 | addCabecera( |
417 | 'Fecha cotizacion:', | 418 | 'Fecha cotizacion:', |
418 | $filter('date')($scope.remito.cotizacion.FECHA, 'dd/MM/yyyy') | 419 | $filter('date')($scope.remito.cotizacion.FECHA, 'dd/MM/yyyy') |
419 | ); | 420 | ); |
420 | addCabecera('Cotizacion:', $scope.remito.cotizacion.COTIZACION); | 421 | addCabecera('Cotizacion:', $scope.remito.cotizacion.COTIZACION); |
421 | $scope.remito.vendedor = {}; | 422 | $scope.remito.vendedor = {}; |
422 | $scope.remito.cliente = {}; | 423 | $scope.remito.cliente = {}; |
423 | $scope.remito.proveedor = {}; | 424 | $scope.remito.proveedor = {}; |
424 | $scope.remito.domicilio = {}; | 425 | $scope.remito.domicilio = {}; |
425 | $scope.remito.flete = null; | 426 | $scope.remito.flete = null; |
426 | $scope.remito.fob = null; | 427 | $scope.remito.fob = null; |
427 | $scope.remito.bomba = null; | 428 | $scope.remito.bomba = null; |
428 | $scope.remito.kilometros = null; | 429 | $scope.remito.kilometros = null; |
429 | $scope.articulosTabla = []; | 430 | $scope.articulosTabla = []; |
430 | crearRemitoService.getNumeroRemito().then( | 431 | crearRemitoService.getNumeroRemito().then( |
431 | function(res) { | 432 | function(res) { |
432 | $scope.puntoVenta = rellenar(res.data.sucursal, 4); | 433 | $scope.puntoVenta = rellenar(res.data.sucursal, 4); |
433 | $scope.comprobante = rellenar(res.data.numeroRemito, 8); | 434 | $scope.comprobante = rellenar(res.data.numeroRemito, 8); |
434 | }, | 435 | }, |
435 | function(err) { | 436 | function(err) { |
436 | focaModalService | 437 | focaModalService |
437 | .alert('La terminal no esta configurada correctamente'); | 438 | .alert('La terminal no esta configurada correctamente'); |
438 | console.info(err); | 439 | console.info(err); |
439 | } | 440 | } |
440 | ); | 441 | ); |
441 | 442 | ||
442 | $scope.notaPedido = { | 443 | $scope.notaPedido = { |
443 | id: 0 | 444 | id: 0 |
444 | }; | 445 | }; |
445 | } | 446 | } |
446 | ); | 447 | ); |
447 | }; | 448 | }; |
448 | 449 | ||
449 | $scope.seleccionarArticulo = function() { | 450 | $scope.seleccionarArticulo = function() { |
450 | if ($scope.idLista === undefined) { | 451 | if ($scope.idLista === undefined) { |
451 | focaModalService.alert( | 452 | focaModalService.alert( |
452 | 'Primero seleccione una lista de precio y condicion'); | 453 | 'Primero seleccione una lista de precio y condicion'); |
453 | return; | 454 | return; |
454 | } | 455 | } |
455 | var modalInstance = $uibModal.open( | 456 | var modalInstance = $uibModal.open( |
456 | { | 457 | { |
457 | ariaLabelledBy: 'Busqueda de Productos', | 458 | ariaLabelledBy: 'Busqueda de Productos', |
458 | templateUrl: 'modal-busqueda-productos.html', | 459 | templateUrl: 'modal-busqueda-productos.html', |
459 | controller: 'modalBusquedaProductosCtrl', | 460 | controller: 'modalBusquedaProductosCtrl', |
460 | resolve: { | 461 | resolve: { |
461 | parametroProducto: { | 462 | parametroProducto: { |
462 | idLista: $scope.idLista, | 463 | idLista: $scope.idLista, |
463 | cotizacion: $scope.remito.cotizacion.COTIZACION, | 464 | cotizacion: $scope.remito.cotizacion.COTIZACION, |
464 | simbolo: $scope.remito.moneda.simbolo | 465 | simbolo: $scope.remito.moneda.simbolo |
465 | } | 466 | } |
466 | }, | 467 | }, |
467 | size: 'lg' | 468 | size: 'lg' |
468 | } | 469 | } |
469 | ); | 470 | ); |
470 | modalInstance.result.then( | 471 | modalInstance.result.then( |
471 | function(producto) { | 472 | function(producto) { |
472 | var newArt = | 473 | var newArt = |
473 | { | 474 | { |
474 | id: 0, | 475 | id: 0, |
475 | codigo: producto.codigo, | 476 | codigo: producto.codigo, |
476 | sector: producto.sector, | 477 | sector: producto.sector, |
477 | sectorCodigo: producto.sector + '-' + producto.codigo, | 478 | sectorCodigo: producto.sector + '-' + producto.codigo, |
478 | descripcion: producto.descripcion, | 479 | descripcion: producto.descripcion, |
479 | item: $scope.articulosTabla.length + 1, | 480 | item: $scope.articulosTabla.length + 1, |
480 | nombre: producto.descripcion, | 481 | nombre: producto.descripcion, |
481 | precio: parseFloat(producto.precio.toFixed(4)), | 482 | precio: parseFloat(producto.precio.toFixed(4)), |
482 | costoUnitario: producto.costo, | 483 | costoUnitario: producto.costo, |
483 | editCantidad: false, | 484 | editCantidad: false, |
484 | editPrecio: false, | 485 | editPrecio: false, |
485 | rubro: producto.CodRub, | 486 | rubro: producto.CodRub, |
486 | exentoUnitario: producto.precio, | 487 | exentoUnitario: producto.precio, |
487 | ivaUnitario: producto.IMPIVA, | 488 | ivaUnitario: producto.IMPIVA, |
488 | impuestoInternoUnitario: producto.ImpInt, | 489 | impuestoInternoUnitario: producto.ImpInt, |
489 | impuestoInterno1Unitario: producto.ImpInt2, | 490 | impuestoInterno1Unitario: producto.ImpInt2, |
490 | impuestoInterno2Unitario: producto.ImpInt3, | 491 | impuestoInterno2Unitario: producto.ImpInt3, |
491 | precioLista: producto.precio, | 492 | precioLista: producto.precio, |
492 | combustible: 1, | 493 | combustible: 1, |
493 | facturado: 0 | 494 | facturado: 0 |
494 | }; | 495 | }; |
495 | $scope.articuloACargar = newArt; | 496 | $scope.articuloACargar = newArt; |
496 | $scope.cargando = false; | 497 | $scope.cargando = false; |
497 | }, function() { | 498 | }, function() { |
498 | // funcion ejecutada cuando se cancela el modal | 499 | // funcion ejecutada cuando se cancela el modal |
499 | } | 500 | } |
500 | ); | 501 | ); |
501 | }; | 502 | }; |
502 | 503 | ||
503 | $scope.seleccionarVendedor = function() { | 504 | $scope.seleccionarVendedor = function() { |
504 | var modalInstance = $uibModal.open( | 505 | var modalInstance = $uibModal.open( |
505 | { | 506 | { |
506 | ariaLabelledBy: 'Busqueda de Vendedores', | 507 | ariaLabelledBy: 'Busqueda de Vendedores', |
507 | templateUrl: 'modal-vendedores.html', | 508 | templateUrl: 'modal-vendedores.html', |
508 | controller: 'modalVendedoresCtrl', | 509 | controller: 'modalVendedoresCtrl', |
509 | size: 'lg' | 510 | size: 'lg' |
510 | } | 511 | } |
511 | ); | 512 | ); |
512 | modalInstance.result.then( | 513 | modalInstance.result.then( |
513 | function(vendedor) { | 514 | function(vendedor) { |
514 | addCabecera('Vendedor:', vendedor.NomVen); | 515 | addCabecera('Vendedor:', vendedor.NomVen); |
515 | $scope.remito.idVendedor = vendedor.CodVen; | 516 | $scope.remito.idVendedor = vendedor.CodVen; |
516 | }, function() { | 517 | }, function() { |
517 | 518 | ||
518 | } | 519 | } |
519 | ); | 520 | ); |
520 | }; | 521 | }; |
521 | 522 | ||
522 | $scope.seleccionarProveedor = function() { | 523 | $scope.seleccionarProveedor = function() { |
523 | var modalInstance = $uibModal.open( | 524 | var modalInstance = $uibModal.open( |
524 | { | 525 | { |
525 | ariaLabelledBy: 'Busqueda de Proveedor', | 526 | ariaLabelledBy: 'Busqueda de Proveedor', |
526 | templateUrl: 'modal-proveedor.html', | 527 | templateUrl: 'modal-proveedor.html', |
527 | controller: 'focaModalProveedorCtrl', | 528 | controller: 'focaModalProveedorCtrl', |
528 | size: 'lg', | 529 | size: 'lg', |
529 | resolve: { | 530 | resolve: { |
530 | transportista: function() { | 531 | transportista: function() { |
531 | return false; | 532 | return false; |
532 | } | 533 | } |
533 | } | 534 | } |
534 | } | 535 | } |
535 | ); | 536 | ); |
536 | modalInstance.result.then( | 537 | modalInstance.result.then( |
537 | function(proveedor) { | 538 | function(proveedor) { |
538 | $scope.remito.idProveedor = proveedor.COD; | 539 | $scope.remito.idProveedor = proveedor.COD; |
539 | addCabecera('Proveedor:', proveedor.NOM); | 540 | addCabecera('Proveedor:', proveedor.NOM); |
540 | }, function() { | 541 | }, function() { |
541 | 542 | ||
542 | } | 543 | } |
543 | ); | 544 | ); |
544 | }; | 545 | }; |
545 | 546 | ||
546 | $scope.seleccionarCliente = function() { | 547 | $scope.seleccionarCliente = function() { |
547 | 548 | ||
548 | var modalInstance = $uibModal.open( | 549 | var modalInstance = $uibModal.open( |
549 | { | 550 | { |
550 | ariaLabelledBy: 'Busqueda de Cliente', | 551 | ariaLabelledBy: 'Busqueda de Cliente', |
551 | templateUrl: 'foca-busqueda-cliente-modal.html', | 552 | templateUrl: 'foca-busqueda-cliente-modal.html', |
552 | controller: 'focaBusquedaClienteModalController', | 553 | controller: 'focaBusquedaClienteModalController', |
553 | size: 'lg' | 554 | size: 'lg' |
554 | } | 555 | } |
555 | ); | 556 | ); |
556 | modalInstance.result.then( | 557 | modalInstance.result.then( |
557 | function(cliente) { | 558 | function(cliente) { |
558 | $scope.abrirModalDomicilios(cliente); | 559 | $scope.abrirModalDomicilios(cliente); |
559 | }, function() { | 560 | }, function() { |
560 | 561 | ||
561 | } | 562 | } |
562 | ); | 563 | ); |
563 | }; | 564 | }; |
564 | 565 | ||
565 | $scope.abrirModalDomicilios = function(cliente) { | 566 | $scope.abrirModalDomicilios = function(cliente) { |
566 | var modalInstanceDomicilio = $uibModal.open( | 567 | var modalInstanceDomicilio = $uibModal.open( |
567 | { | 568 | { |
568 | ariaLabelledBy: 'Busqueda de Domicilios', | 569 | ariaLabelledBy: 'Busqueda de Domicilios', |
569 | templateUrl: 'modal-domicilio.html', | 570 | templateUrl: 'modal-domicilio.html', |
570 | controller: 'focaModalDomicilioController', | 571 | controller: 'focaModalDomicilioController', |
571 | size: 'lg', | 572 | size: 'lg', |
572 | resolve: { idCliente: function() { return cliente.cod; }} | 573 | resolve: { idCliente: function() { return cliente.cod; }} |
573 | } | 574 | } |
574 | ); | 575 | ); |
575 | modalInstanceDomicilio.result.then( | 576 | modalInstanceDomicilio.result.then( |
576 | function(domicilio) { | 577 | function(domicilio) { |
577 | //$scope.remito.domicilio.id = domicilio.nivel2; | 578 | //$scope.remito.domicilio.id = domicilio.nivel2; |
578 | $scope.remito.cliente = { | 579 | $scope.remito.cliente = { |
579 | COD: cliente.cod, | 580 | COD: cliente.cod, |
580 | CUIT: cliente.cuit, | 581 | CUIT: cliente.cuit, |
581 | NOM: cliente.nom | 582 | NOM: cliente.nom |
582 | }; | 583 | }; |
583 | 584 | ||
584 | addCabecera('Cliente:', cliente.nom); | 585 | addCabecera('Cliente:', cliente.nom); |
585 | var domicilioStamp = | 586 | var domicilioStamp = |
586 | domicilio.Calle + ' ' + domicilio.Numero + ', ' + | 587 | domicilio.Calle + ' ' + domicilio.Numero + ', ' + |
587 | domicilio.Localidad + ', ' + domicilio.Provincia; | 588 | domicilio.Localidad + ', ' + domicilio.Provincia; |
588 | $scope.remito.domicilioStamp = domicilioStamp; | 589 | $scope.remito.domicilioStamp = domicilioStamp; |
589 | addCabecera('Domicilio:', domicilioStamp); | 590 | addCabecera('Domicilio:', domicilioStamp); |
590 | }, function() { | 591 | }, function() { |
591 | $scope.seleccionarCliente(); | 592 | $scope.seleccionarCliente(); |
592 | return; | 593 | return; |
593 | } | 594 | } |
594 | ); | 595 | ); |
595 | }; | 596 | }; |
596 | 597 | ||
597 | $scope.mostrarFichaCliente = function() { | 598 | $scope.mostrarFichaCliente = function() { |
598 | $uibModal.open( | 599 | $uibModal.open( |
599 | { | 600 | { |
600 | ariaLabelledBy: 'Datos del Cliente', | 601 | ariaLabelledBy: 'Datos del Cliente', |
601 | templateUrl: 'foca-crear-remito-ficha-cliente.html', | 602 | templateUrl: 'foca-crear-remito-ficha-cliente.html', |
602 | controller: 'focaCrearRemitoFichaClienteController', | 603 | controller: 'focaCrearRemitoFichaClienteController', |
603 | size: 'lg' | 604 | size: 'lg' |
604 | } | 605 | } |
605 | ); | 606 | ); |
606 | }; | 607 | }; |
607 | 608 | ||
608 | $scope.getTotal = function() { | 609 | $scope.getTotal = function() { |
609 | var total = 0; | 610 | var total = 0; |
610 | var arrayTempArticulos = $scope.articulosTabla; | 611 | var arrayTempArticulos = $scope.articulosTabla; |
611 | for (var i = 0; i < arrayTempArticulos.length; i++) { | 612 | for (var i = 0; i < arrayTempArticulos.length; i++) { |
612 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; | 613 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; |
613 | } | 614 | } |
614 | return parseFloat(total.toFixed(2)); | 615 | return parseFloat(total.toFixed(2)); |
615 | }; | 616 | }; |
616 | 617 | ||
617 | $scope.getSubTotal = function() { | 618 | $scope.getSubTotal = function() { |
618 | if($scope.articuloACargar) { | 619 | if($scope.articuloACargar) { |
619 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; | 620 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; |
620 | } | 621 | } |
621 | }; | 622 | }; |
622 | 623 | ||
623 | $scope.abrirModalListaPrecio = function() { | 624 | $scope.abrirModalListaPrecio = function() { |
624 | var modalInstance = $uibModal.open( | 625 | var modalInstance = $uibModal.open( |
625 | { | 626 | { |
626 | ariaLabelledBy: 'Busqueda de Precio Condición', | 627 | ariaLabelledBy: 'Busqueda de Precio Condición', |
627 | templateUrl: 'modal-precio-condicion.html', | 628 | templateUrl: 'modal-precio-condicion.html', |
628 | controller: 'focaModalPrecioCondicionController', | 629 | controller: 'focaModalPrecioCondicionController', |
629 | size: 'lg' | 630 | size: 'lg' |
630 | } | 631 | } |
631 | ); | 632 | ); |
632 | modalInstance.result.then( | 633 | modalInstance.result.then( |
633 | function(precioCondicion) { | 634 | function(precioCondicion) { |
634 | var cabecera = ''; | 635 | var cabecera = ''; |
635 | var plazosConcat = ''; | 636 | var plazosConcat = ''; |
636 | if(!Array.isArray(precioCondicion)) { | 637 | if(!Array.isArray(precioCondicion)) { |
637 | $scope.remito.idPrecioCondicion = precioCondicion.id; | 638 | $scope.remito.idPrecioCondicion = precioCondicion.id; |
638 | $scope.plazosPagos = precioCondicion.plazoPago; | 639 | $scope.plazosPagos = precioCondicion.plazoPago; |
639 | $scope.idLista = precioCondicion.idListaPrecio; | 640 | $scope.idLista = precioCondicion.idListaPrecio; |
640 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { | 641 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { |
641 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; | 642 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; |
642 | } | 643 | } |
643 | cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); | 644 | cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); |
644 | } else { //Cuando se ingresan los plazos manualmente | 645 | } else { //Cuando se ingresan los plazos manualmente |
645 | $scope.remito.idPrecioCondicion = 0; | 646 | $scope.remito.idPrecioCondicion = 0; |
646 | $scope.idLista = -1; //-1, el modal productos busca todos los productos | 647 | $scope.idLista = -1; //-1, el modal productos busca todos los productos |
647 | $scope.plazosPagos = precioCondicion; | 648 | $scope.plazosPagos = precioCondicion; |
648 | for(var j = 0; j < precioCondicion.length; j++) { | 649 | for(var j = 0; j < precioCondicion.length; j++) { |
649 | plazosConcat += precioCondicion[j].dias + ' '; | 650 | plazosConcat += precioCondicion[j].dias + ' '; |
650 | } | 651 | } |
651 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); | 652 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); |
652 | } | 653 | } |
653 | $scope.articulosTabla = []; | 654 | $scope.articulosTabla = []; |
654 | addCabecera('Precios y condiciones:', cabecera); | 655 | addCabecera('Precios y condiciones:', cabecera); |
655 | }, function() { | 656 | }, function() { |
656 | 657 | ||
657 | } | 658 | } |
658 | ); | 659 | ); |
659 | }; | 660 | }; |
660 | 661 | ||
661 | $scope.abrirModalFlete = function() { | 662 | $scope.abrirModalFlete = function() { |
662 | var modalInstance = $uibModal.open( | 663 | var modalInstance = $uibModal.open( |
663 | { | 664 | { |
664 | ariaLabelledBy: 'Busqueda de Flete', | 665 | ariaLabelledBy: 'Busqueda de Flete', |
665 | templateUrl: 'modal-flete.html', | 666 | templateUrl: 'modal-flete.html', |
666 | controller: 'focaModalFleteController', | 667 | controller: 'focaModalFleteController', |
667 | size: 'lg', | 668 | size: 'lg', |
668 | resolve: { | 669 | resolve: { |
669 | parametrosFlete: | 670 | parametrosFlete: |
670 | function() { | 671 | function() { |
671 | return { | 672 | return { |
672 | flete: $scope.remito.flete ? '1' : | 673 | flete: $scope.remito.flete ? '1' : |
673 | ($scope.remito.fob ? 'FOB' : | 674 | ($scope.remito.fob ? 'FOB' : |
674 | ($scope.remito.flete === undefined ? null : '0')), | 675 | ($scope.remito.flete === undefined ? null : '0')), |
675 | bomba: $scope.remito.bomba ? '1' : | 676 | bomba: $scope.remito.bomba ? '1' : |
676 | ($scope.remito.bomba === undefined ? null : '0'), | 677 | ($scope.remito.bomba === undefined ? null : '0'), |
677 | kilometros: $scope.remito.kilometros | 678 | kilometros: $scope.remito.kilometros |
678 | }; | 679 | }; |
679 | } | 680 | } |
680 | } | 681 | } |
681 | } | 682 | } |
682 | ); | 683 | ); |
683 | modalInstance.result.then( | 684 | modalInstance.result.then( |
684 | function(datos) { | 685 | function(datos) { |
685 | $scope.remito.flete = datos.flete; | 686 | $scope.remito.flete = datos.flete; |
686 | $scope.remito.fob = datos.FOB; | 687 | $scope.remito.fob = datos.FOB; |
687 | $scope.remito.bomba = datos.bomba; | 688 | $scope.remito.bomba = datos.bomba; |
688 | $scope.remito.kilometros = datos.kilometros; | 689 | $scope.remito.kilometros = datos.kilometros; |
689 | 690 | ||
690 | addCabecera('Flete:', datos.flete ? 'Si' : | 691 | addCabecera('Flete:', datos.flete ? 'Si' : |
691 | ($scope.remito.fob ? 'FOB' : 'No')); | 692 | ($scope.remito.fob ? 'FOB' : 'No')); |
692 | if(datos.flete) { | 693 | if(datos.flete) { |
693 | addCabecera('Bomba:', datos.bomba ? 'Si' : 'No'); | 694 | addCabecera('Bomba:', datos.bomba ? 'Si' : 'No'); |
694 | addCabecera('Kilometros:', datos.kilometros); | 695 | addCabecera('Kilometros:', datos.kilometros); |
695 | } else { | 696 | } else { |
696 | removeCabecera('Bomba:'); | 697 | removeCabecera('Bomba:'); |
697 | removeCabecera('Kilometros:'); | 698 | removeCabecera('Kilometros:'); |
698 | $scope.remito.fob = false; | 699 | $scope.remito.fob = false; |
699 | $scope.remito.bomba = false; | 700 | $scope.remito.bomba = false; |
700 | $scope.remito.kilometros = null; | 701 | $scope.remito.kilometros = null; |
701 | } | 702 | } |
702 | }, function() { | 703 | }, function() { |
703 | 704 | ||
704 | } | 705 | } |
705 | ); | 706 | ); |
706 | }; | 707 | }; |
707 | 708 | ||
708 | $scope.abrirModalMoneda = function() { | 709 | $scope.abrirModalMoneda = function() { |
709 | var modalInstance = $uibModal.open( | 710 | var modalInstance = $uibModal.open( |
710 | { | 711 | { |
711 | ariaLabelledBy: 'Busqueda de Moneda', | 712 | ariaLabelledBy: 'Busqueda de Moneda', |
712 | templateUrl: 'modal-moneda.html', | 713 | templateUrl: 'modal-moneda.html', |
713 | controller: 'focaModalMonedaController', | 714 | controller: 'focaModalMonedaController', |
714 | size: 'lg' | 715 | size: 'lg' |
715 | } | 716 | } |
716 | ); | 717 | ); |
717 | modalInstance.result.then( | 718 | modalInstance.result.then( |
718 | function(moneda) { | 719 | function(moneda) { |
719 | $scope.abrirModalCotizacion(moneda); | 720 | $scope.abrirModalCotizacion(moneda); |
720 | }, function() { | 721 | }, function() { |
721 | 722 | ||
722 | } | 723 | } |
723 | ); | 724 | ); |
724 | }; | 725 | }; |
725 | 726 | ||
726 | $scope.abrirModalCotizacion = function(moneda) { | 727 | $scope.abrirModalCotizacion = function(moneda) { |
727 | var modalInstance = $uibModal.open( | 728 | var modalInstance = $uibModal.open( |
728 | { | 729 | { |
729 | ariaLabelledBy: 'Busqueda de Cotización', | 730 | ariaLabelledBy: 'Busqueda de Cotización', |
730 | templateUrl: 'modal-cotizacion.html', | 731 | templateUrl: 'modal-cotizacion.html', |
731 | controller: 'focaModalCotizacionController', | 732 | controller: 'focaModalCotizacionController', |
732 | size: 'lg', | 733 | size: 'lg', |
733 | resolve: {idMoneda: function() {return moneda.ID;}} | 734 | resolve: {idMoneda: function() {return moneda.ID;}} |
734 | } | 735 | } |
735 | ); | 736 | ); |
736 | modalInstance.result.then( | 737 | modalInstance.result.then( |
737 | function(cotizacion) { | 738 | function(cotizacion) { |
738 | var articulosTablaTemp = $scope.articulosTabla; | 739 | var articulosTablaTemp = $scope.articulosTabla; |
739 | for(var i = 0; i < articulosTablaTemp.length; i++) { | 740 | for(var i = 0; i < articulosTablaTemp.length; i++) { |
740 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * | 741 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * |
741 | $scope.remito.cotizacion.COTIZACION; | 742 | $scope.remito.cotizacion.COTIZACION; |
742 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / | 743 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / |
743 | cotizacion.COTIZACION; | 744 | cotizacion.COTIZACION; |
744 | } | 745 | } |
745 | $scope.articulosTabla = articulosTablaTemp; | 746 | $scope.articulosTabla = articulosTablaTemp; |
746 | $scope.remito.moneda = moneda; | 747 | $scope.remito.moneda = moneda; |
747 | $scope.remito.cotizacion = cotizacion; | 748 | $scope.remito.cotizacion = cotizacion; |
748 | addCabecera('Moneda:', moneda.DETALLE); | 749 | addCabecera('Moneda:', moneda.DETALLE); |
749 | addCabecera( | 750 | addCabecera( |
750 | 'Fecha cotizacion:', | 751 | 'Fecha cotizacion:', |
751 | $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') | 752 | $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') |
752 | ); | 753 | ); |
753 | addCabecera('Cotizacion:', cotizacion.COTIZACION); | 754 | addCabecera('Cotizacion:', cotizacion.COTIZACION); |
754 | }, function() { | 755 | }, function() { |
755 | 756 | ||
756 | } | 757 | } |
757 | ); | 758 | ); |
758 | }; | 759 | }; |
759 | 760 | ||
760 | $scope.agregarATabla = function(key) { | 761 | $scope.agregarATabla = function(key) { |
761 | if(key === 13) { | 762 | if(key === 13) { |
762 | if($scope.articuloACargar.cantidad === undefined || | 763 | if($scope.articuloACargar.cantidad === undefined || |
763 | $scope.articuloACargar.cantidad === 0 || | 764 | $scope.articuloACargar.cantidad === 0 || |
764 | $scope.articuloACargar.cantidad === null ) { | 765 | $scope.articuloACargar.cantidad === null ) { |
765 | focaModalService.alert('El valor debe ser al menos 1'); | 766 | focaModalService.alert('El valor debe ser al menos 1'); |
766 | return; | 767 | return; |
767 | } | 768 | } |
768 | delete $scope.articuloACargar.sectorCodigo; | 769 | delete $scope.articuloACargar.sectorCodigo; |
769 | $scope.articulosTabla.push($scope.articuloACargar); | 770 | $scope.articulosTabla.push($scope.articuloACargar); |
770 | $scope.cargando = true; | 771 | $scope.cargando = true; |
771 | } | 772 | } |
772 | }; | 773 | }; |
773 | 774 | ||
774 | $scope.quitarArticulo = function(key) { | 775 | $scope.quitarArticulo = function(key) { |
775 | $scope.articulosTabla.splice(key, 1); | 776 | $scope.articulosTabla.splice(key, 1); |
776 | }; | 777 | }; |
777 | 778 | ||
778 | $scope.editarArticulo = function(key, articulo) { | 779 | $scope.editarArticulo = function(key, articulo) { |
779 | if(key === 13) { | 780 | if(key === 13) { |
780 | if(articulo.cantidad === null || articulo.cantidad === 0 || | 781 | if(articulo.cantidad === null || articulo.cantidad === 0 || |
781 | articulo.cantidad === undefined) { | 782 | articulo.cantidad === undefined) { |
782 | focaModalService.alert('El valor debe ser al menos 1'); | 783 | focaModalService.alert('El valor debe ser al menos 1'); |
783 | return; | 784 | return; |
784 | } | 785 | } |
785 | articulo.editCantidad = false; | 786 | articulo.editCantidad = false; |
786 | articulo.editPrecio = false; | 787 | articulo.editPrecio = false; |
787 | } | 788 | } |
788 | }; | 789 | }; |
789 | 790 | ||
790 | $scope.cambioEdit = function(articulo, propiedad) { | 791 | $scope.cambioEdit = function(articulo, propiedad) { |
791 | if(propiedad === 'cantidad') { | 792 | if(propiedad === 'cantidad') { |
792 | articulo.editCantidad = true; | 793 | articulo.editCantidad = true; |
793 | } else if(propiedad === 'precio') { | 794 | } else if(propiedad === 'precio') { |
794 | articulo.editPrecio = true; | 795 | articulo.editPrecio = true; |
795 | } | 796 | } |
796 | }; | 797 | }; |
797 | 798 | ||
798 | $scope.limpiarFlete = function() { | 799 | $scope.limpiarFlete = function() { |
799 | $scope.remito.fleteNombre = ''; | 800 | $scope.remito.fleteNombre = ''; |
800 | $scope.remito.chofer = ''; | 801 | $scope.remito.chofer = ''; |
801 | $scope.remito.vehiculo = ''; | 802 | $scope.remito.vehiculo = ''; |
802 | $scope.remito.kilometros = ''; | 803 | $scope.remito.kilometros = ''; |
803 | $scope.remito.costoUnitarioKmFlete = ''; | 804 | $scope.remito.costoUnitarioKmFlete = ''; |
804 | $scope.choferes = ''; | 805 | $scope.choferes = ''; |
805 | $scope.vehiculos = ''; | 806 | $scope.vehiculos = ''; |
806 | }; | 807 | }; |
807 | 808 | ||
808 | $scope.limpiarPantalla = function() { | 809 | $scope.limpiarPantalla = function() { |
809 | $scope.limpiarFlete(); | 810 | $scope.limpiarFlete(); |
810 | $scope.remito.flete = '0'; | 811 | $scope.remito.flete = '0'; |
811 | $scope.remito.bomba = '0'; | 812 | $scope.remito.bomba = '0'; |
812 | $scope.remito.precioCondicion = ''; | 813 | $scope.remito.precioCondicion = ''; |
813 | $scope.articulosTabla = []; | 814 | $scope.articulosTabla = []; |
814 | $scope.remito.vendedor.nombre = ''; | 815 | $scope.remito.vendedor.nombre = ''; |
815 | $scope.remito.cliente = {nombre: ''}; | 816 | $scope.remito.cliente = {nombre: ''}; |
816 | $scope.remito.domicilio = {dom: ''}; | 817 | $scope.remito.domicilio = {dom: ''}; |
817 | $scope.domiciliosCliente = []; | 818 | $scope.domiciliosCliente = []; |
818 | }; | 819 | }; |
819 | 820 | ||
820 | $scope.resetFilter = function() { | 821 | $scope.resetFilter = function() { |
821 | $scope.articuloACargar = {}; | 822 | $scope.articuloACargar = {}; |
822 | $scope.cargando = true; | 823 | $scope.cargando = true; |
823 | }; | 824 | }; |
824 | 825 | ||
825 | $scope.selectFocus = function($event) { | 826 | $scope.selectFocus = function($event) { |
826 | $event.target.select(); | 827 | $event.target.select(); |
827 | }; | 828 | }; |
828 | 829 | ||
829 | $scope.salir = function() { | 830 | $scope.salir = function() { |
830 | $location.path('/'); | 831 | $location.path('/'); |
831 | }; | 832 | }; |
832 | function addArrayCabecera(array) { | 833 | function addArrayCabecera(array) { |
833 | for(var i = 0; i < array.length; i++) { | 834 | for(var i = 0; i < array.length; i++) { |
834 | addCabecera(array[i].label, array[i].valor); | 835 | addCabecera(array[i].label, array[i].valor); |
835 | } | 836 | } |
836 | } | 837 | } |
837 | 838 | ||
838 | function addCabecera(label, valor) { | 839 | function addCabecera(label, valor) { |
839 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); | 840 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); |
840 | if(propiedad.length === 1) { | 841 | if(propiedad.length === 1) { |
841 | propiedad[0].valor = valor; | 842 | propiedad[0].valor = valor; |
842 | } else { | 843 | } else { |
843 | $scope.cabecera.push({label: label, valor: valor}); | 844 | $scope.cabecera.push({label: label, valor: valor}); |
844 | } | 845 | } |
845 | } | 846 | } |
846 | 847 | ||
847 | function removeCabecera(label) { | 848 | function removeCabecera(label) { |
848 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); | 849 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); |
849 | if(propiedad.length === 1) { | 850 | if(propiedad.length === 1) { |
850 | $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); | 851 | $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); |
851 | } | 852 | } |
852 | } | 853 | } |
853 | 854 | ||
854 | function rellenar(relleno, longitud) { | 855 | function rellenar(relleno, longitud) { |
855 | relleno = '' + relleno; | 856 | relleno = '' + relleno; |
856 | while (relleno.length < longitud) { | 857 | while (relleno.length < longitud) { |
857 | relleno = '0' + relleno; | 858 | relleno = '0' + relleno; |
858 | } | 859 | } |
859 | 860 | ||
860 | return relleno; | 861 | return relleno; |
861 | } | 862 | } |
862 | } | 863 | } |
863 | ] | 864 | ] |
864 | ) | 865 | ) |
865 | .controller('remitoListaCtrl', [ | 866 | .controller('remitoListaCtrl', [ |
866 | '$scope', | 867 | '$scope', |
867 | 'crearRemitoService', | 868 | 'crearRemitoService', |
868 | '$location', | 869 | '$location', |
869 | function($scope, crearRemitoService, $location) { | 870 | function($scope, crearRemitoService, $location) { |
870 | crearRemitoService.obtenerRemito().then(function(datos) { | 871 | crearRemitoService.obtenerRemito().then(function(datos) { |
871 | $scope.remitos = datos.data; | 872 | $scope.remitos = datos.data; |
872 | }); | 873 | }); |
873 | $scope.editar = function(remito) { | 874 | $scope.editar = function(remito) { |
874 | crearRemitoService.setRemito(remito); | 875 | crearRemitoService.setRemito(remito); |
875 | $location.path('/venta-nota-remito/abm/'); | 876 | $location.path('/venta-nota-remito/abm/'); |
876 | }; | 877 | }; |
877 | $scope.crearRemito = function() { | 878 | $scope.crearRemito = function() { |
878 | crearRemitoService.clearRemito(); | 879 | crearRemitoService.clearRemito(); |
879 | $location.path('/venta-nota-remito/abm/'); | 880 | $location.path('/venta-nota-remito/abm/'); |
880 | }; | 881 | }; |
881 | } | 882 | } |
882 | ]) | 883 | ]) |
883 | .controller('focaCrearRemitoFichaClienteController', [ | 884 | .controller('focaCrearRemitoFichaClienteController', [ |
884 | '$scope', | 885 | '$scope', |
885 | 'crearRemitoService', | 886 | 'crearRemitoService', |
886 | '$location', | 887 | '$location', |
887 | function($scope, crearRemitoService, $location) { | 888 | function($scope, crearRemitoService, $location) { |
888 | crearRemitoService.obtenerRemito().then(function(datos) { | 889 | crearRemitoService.obtenerRemito().then(function(datos) { |
889 | $scope.remitos = datos.data; | 890 | $scope.remitos = datos.data; |
890 | }); | 891 | }); |
891 | $scope.editar = function(remito) { | 892 | $scope.editar = function(remito) { |
892 | crearRemitoService.setRemito(remito); | 893 | crearRemitoService.setRemito(remito); |
893 | $location.path('/venta-nota-remito/abm/'); | 894 | $location.path('/venta-nota-remito/abm/'); |
894 | }; | 895 | }; |
895 | $scope.crearRemito = function() { | 896 | $scope.crearRemito = function() { |
896 | crearRemitoService.clearRemito(); | 897 | crearRemitoService.clearRemito(); |
897 | $location.path('/venta-nota-remito/abm/'); | 898 | $location.path('/venta-nota-remito/abm/'); |
898 | }; | 899 | }; |
899 | } | 900 | } |
900 | ]); | 901 | ]); |
901 | 902 |