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