Commit 8c5f5976a2ee5ee3a2c79ee536ec6d76d9cef651
1 parent
68a8009d63
Exists in
master
signos para cumplir pre-commit
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 | vendedor: {}, | 31 | vendedor: {}, |
32 | cliente: {}, | 32 | cliente: {}, |
33 | proveedor: {}, | 33 | proveedor: {}, |
34 | domicilio: {dom: ''}, | 34 | domicilio: {dom: ''}, |
35 | moneda: {}, | 35 | moneda: {}, |
36 | cotizacion: {} | 36 | cotizacion: {} |
37 | }; | 37 | }; |
38 | var monedaPorDefecto; | 38 | var monedaPorDefecto; |
39 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' | 39 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' |
40 | crearRemitoService.getCotizacionByIdMoneda(1).then(function(res) { | 40 | crearRemitoService.getCotizacionByIdMoneda(1).then(function(res) { |
41 | monedaPorDefecto = { | 41 | monedaPorDefecto = { |
42 | id: res.data[0].ID, | 42 | id: res.data[0].ID, |
43 | detalle: res.data[0].DETALLE, | 43 | detalle: res.data[0].DETALLE, |
44 | simbolo: res.data[0].SIMBOLO, | 44 | simbolo: res.data[0].SIMBOLO, |
45 | cotizaciones: res.data[0].cotizaciones | 45 | cotizaciones: res.data[0].cotizaciones |
46 | }; | 46 | }; |
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].COTIZACION); | 50 | addCabecera('Cotizacion:', monedaPorDefecto.cotizaciones[0].COTIZACION); |
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 = Math.round(Math.random() * 10000); | 59 | $scope.puntoVenta = Math.round(Math.random() * 10000); |
60 | $scope.comprobante = Math.round(Math.random() * 1000000); | 60 | $scope.comprobante = Math.round(Math.random() * 1000000); |
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.numeroNotaPedido, 8); | 76 | $scope.comprobante = rellenar(res.data.numeroNotaPedido, 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 | resolve: { | 90 | resolve: { |
91 | parametroNotaPedido: { | 91 | parametroNotaPedido: { |
92 | idLista: $scope.idLista, | 92 | idLista: $scope.idLista, |
93 | cotizacion: $scope.remito.cotizacion.COTIZACION, | 93 | cotizacion: $scope.remito.cotizacion.COTIZACION, |
94 | simbolo: $scope.remito.moneda.simbolo | 94 | simbolo: $scope.remito.moneda.simbolo |
95 | } | 95 | } |
96 | }, | 96 | }, |
97 | size: 'lg' | 97 | size: 'lg' |
98 | } | 98 | } |
99 | ); | 99 | ); |
100 | modalInstance.result.then( | 100 | modalInstance.result.then( |
101 | function(producto) { | 101 | function(producto) { |
102 | var newArt = | 102 | var newArt = |
103 | { | 103 | { |
104 | id: 0, | 104 | id: 0, |
105 | codigo: producto.codigo, | 105 | codigo: producto.codigo, |
106 | sector: producto.sector, | 106 | sector: producto.sector, |
107 | sectorCodigo: producto.sector + '-' + producto.codigo, | 107 | sectorCodigo: producto.sector + '-' + producto.codigo, |
108 | descripcion: producto.descripcion, | 108 | descripcion: producto.descripcion, |
109 | item: $scope.articulosTabla.length + 1, | 109 | item: $scope.articulosTabla.length + 1, |
110 | nombre: producto.descripcion, | 110 | nombre: producto.descripcion, |
111 | precio: parseFloat(producto.precio.toFixed(4)), | 111 | precio: parseFloat(producto.precio.toFixed(4)), |
112 | costoUnitario: producto.costo, | 112 | costoUnitario: producto.costo, |
113 | editCantidad: false, | 113 | editCantidad: false, |
114 | editPrecio: false | 114 | editPrecio: false |
115 | }; | 115 | }; |
116 | $scope.articuloACargar = newArt; | 116 | $scope.articuloACargar = newArt; |
117 | $scope.cargando = false; | 117 | $scope.cargando = false; |
118 | }, function() { | 118 | }, function() { |
119 | // funcion ejecutada cuando se cancela el modal | 119 | // funcion ejecutada cuando se cancela el modal |
120 | } | 120 | } |
121 | ); | 121 | ); |
122 | } | 122 | }; |
123 | |||
123 | $scope.seleccionarRemito = function() { | 124 | $scope.seleccionarRemito = function() { |
124 | var modalInstance = $uibModal.open( | 125 | var modalInstance = $uibModal.open( |
125 | { | 126 | { |
126 | ariaLabelledBy: 'Busqueda de Remito', | 127 | ariaLabelledBy: 'Busqueda de Remito', |
127 | templateUrl: 'foca-modal-remito.html', | 128 | templateUrl: 'foca-modal-remito.html', |
128 | controller: 'focaModalRemitoController', | 129 | controller: 'focaModalRemitoController', |
129 | resolve: { | 130 | resolve: { |
130 | parametroRemito: { | 131 | parametroRemito: { |
131 | idLista: $scope.idLista, | 132 | idLista: $scope.idLista, |
132 | cotizacion: $scope.remito.cotizacion.COTIZACION, | 133 | cotizacion: $scope.remito.cotizacion.COTIZACION, |
133 | simbolo: $scope.remito.moneda.simbolo | 134 | simbolo: $scope.remito.moneda.simbolo |
134 | } | 135 | } |
135 | }, | 136 | }, |
136 | size: 'lg' | 137 | size: 'lg' |
137 | } | 138 | } |
138 | ); | 139 | ); |
139 | modalInstance.result.then( | 140 | modalInstance.result.then( |
140 | function(producto) { | 141 | function(producto) { |
141 | var newArt = | 142 | var newArt = |
142 | { | 143 | { |
143 | id: 0, | 144 | id: 0, |
144 | codigo: producto.codigo, | 145 | codigo: producto.codigo, |
145 | sector: producto.sector, | 146 | sector: producto.sector, |
146 | sectorCodigo: producto.sector + '-' + producto.codigo, | 147 | sectorCodigo: producto.sector + '-' + producto.codigo, |
147 | descripcion: producto.descripcion, | 148 | descripcion: producto.descripcion, |
148 | item: $scope.articulosTabla.length + 1, | 149 | item: $scope.articulosTabla.length + 1, |
149 | nombre: producto.descripcion, | 150 | nombre: producto.descripcion, |
150 | precio: parseFloat(producto.precio.toFixed(4)), | 151 | precio: parseFloat(producto.precio.toFixed(4)), |
151 | costoUnitario: producto.costo, | 152 | costoUnitario: producto.costo, |
152 | editCantidad: false, | 153 | editCantidad: false, |
153 | editPrecio: false | 154 | editPrecio: false |
154 | }; | 155 | }; |
155 | $scope.articuloACargar = newArt; | 156 | $scope.articuloACargar = newArt; |
156 | $scope.cargando = false; | 157 | $scope.cargando = false; |
157 | }, function() { | 158 | }, function() { |
158 | // funcion ejecutada cuando se cancela el modal | 159 | // funcion ejecutada cuando se cancela el modal |
159 | } | 160 | } |
160 | ); | 161 | ); |
161 | } | 162 | }; |
162 | 163 | ||
163 | //La pantalla solo se usa para cargar remitos | 164 | //La pantalla solo se usa para cargar remitos |
164 | // if (remitoTemp !== undefined) { | 165 | // if (remitoTemp !== undefined) { |
165 | // remitoTemp.fechaCarga = new Date(remitoTemp.fechaCarga); | 166 | // remitoTemp.fechaCarga = new Date(remitoTemp.fechaCarga); |
166 | // $scope.remito = remitoTemp; | 167 | // $scope.remito = remitoTemp; |
167 | // $scope.remito.flete = ($scope.remito.flete).toString(); | 168 | // $scope.remito.flete = ($scope.remito.flete).toString(); |
168 | // $scope.remito.bomba = ($scope.remito.bomba).toString(); | 169 | // $scope.remito.bomba = ($scope.remito.bomba).toString(); |
169 | // $scope.idLista = $scope.remito.precioCondicion; | 170 | // $scope.idLista = $scope.remito.precioCondicion; |
170 | // crearRemitoService | 171 | // crearRemitoService |
171 | // .getArticulosByIdRemito($scope.remito.id).then( | 172 | // .getArticulosByIdRemito($scope.remito.id).then( |
172 | // function(res) { | 173 | // function(res) { |
173 | // $scope.articulosTabla = res.data; | 174 | // $scope.articulosTabla = res.data; |
174 | // } | 175 | // } |
175 | // ); | 176 | // ); |
176 | //TODO DOMICILIOS QUE SE CARGAN AL EDITAR REMITO | 177 | //TODO DOMICILIOS QUE SE CARGAN AL EDITAR REMITO |
177 | //(NO REQUERIDO EN ESTA VERSION) | 178 | //(NO REQUERIDO EN ESTA VERSION) |
178 | // crearRemitoService.getDomiciliosByIdRemito($scope.remito.id).then( | 179 | // crearRemitoService.getDomiciliosByIdRemito($scope.remito.id).then( |
179 | // function(res) { | 180 | // function(res) { |
180 | // $scope.remito.domicilio = res.data; | 181 | // $scope.remito.domicilio = res.data; |
181 | // } | 182 | // } |
182 | // ); | 183 | // ); |
183 | // } else { | 184 | // } else { |
184 | // $scope.remito.fechaCarga = new Date(); | 185 | // $scope.remito.fechaCarga = new Date(); |
185 | // $scope.remito.bomba = '0'; | 186 | // $scope.remito.bomba = '0'; |
186 | // $scope.remito.flete = '0'; | 187 | // $scope.remito.flete = '0'; |
187 | // $scope.idLista = undefined; | 188 | // $scope.idLista = undefined; |
188 | // } | 189 | // } |
189 | //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO | 190 | //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO |
190 | // $scope.addNewDom = function() { | 191 | // $scope.addNewDom = function() { |
191 | // $scope.remito.domicilio.push({ 'id': 0 }); | 192 | // $scope.remito.domicilio.push({ 'id': 0 }); |
192 | // }; | 193 | // }; |
193 | // $scope.removeNewChoice = function(choice) { | 194 | // $scope.removeNewChoice = function(choice) { |
194 | // if ($scope.remito.domicilio.length > 1) { | 195 | // if ($scope.remito.domicilio.length > 1) { |
195 | // $scope.remito.domicilio.splice($scope.remito.domicilio.findIndex( | 196 | // $scope.remito.domicilio.splice($scope.remito.domicilio.findIndex( |
196 | // function(c) { | 197 | // function(c) { |
197 | // return c.$$hashKey === choice.$$hashKey; | 198 | // return c.$$hashKey === choice.$$hashKey; |
198 | // } | 199 | // } |
199 | // ), 1); | 200 | // ), 1); |
200 | // } | 201 | // } |
201 | // }; | 202 | // }; |
202 | 203 | ||
203 | $scope.crearRemito = function() { | 204 | $scope.crearRemito = function() { |
204 | if(!$scope.remito.vendedor.codigo) { | 205 | if(!$scope.remito.vendedor.codigo) { |
205 | focaModalService.alert('Ingrese Vendedor'); | 206 | focaModalService.alert('Ingrese Vendedor'); |
206 | return; | 207 | return; |
207 | } else if(!$scope.remito.cliente.cod) { | 208 | } else if(!$scope.remito.cliente.cod) { |
208 | focaModalService.alert('Ingrese Cliente'); | 209 | focaModalService.alert('Ingrese Cliente'); |
209 | return; | 210 | return; |
210 | } else if(!$scope.remito.proveedor.codigo) { | 211 | } else if(!$scope.remito.proveedor.codigo) { |
211 | focaModalService.alert('Ingrese Proveedor'); | 212 | focaModalService.alert('Ingrese Proveedor'); |
212 | return; | 213 | return; |
213 | } else if(!$scope.remito.moneda.id) { | 214 | } else if(!$scope.remito.moneda.id) { |
214 | focaModalService.alert('Ingrese Moneda'); | 215 | focaModalService.alert('Ingrese Moneda'); |
215 | return; | 216 | return; |
216 | } else if(!$scope.remito.cotizacion.ID) { | 217 | } else if(!$scope.remito.cotizacion.ID) { |
217 | focaModalService.alert('Ingrese Cotización'); | 218 | focaModalService.alert('Ingrese Cotización'); |
218 | return; | 219 | return; |
219 | } else if(!$scope.plazosPagos) { | 220 | } else if(!$scope.plazosPagos) { |
220 | focaModalService.alert('Ingrese Precios y Condiciones'); | 221 | focaModalService.alert('Ingrese Precios y Condiciones'); |
221 | return; | 222 | return; |
222 | } else if( | 223 | } else if( |
223 | $scope.remito.flete === undefined || $scope.remito.flete === null) | 224 | $scope.remito.flete === undefined || $scope.remito.flete === null) |
224 | { | 225 | { |
225 | focaModalService.alert('Ingrese Flete'); | 226 | focaModalService.alert('Ingrese Flete'); |
226 | return; | 227 | return; |
227 | } else if(!$scope.remito.domicilio.id) { | 228 | } else if(!$scope.remito.domicilio.id) { |
228 | focaModalService.alert('Ingrese Domicilio'); | 229 | focaModalService.alert('Ingrese Domicilio'); |
229 | return; | 230 | return; |
230 | } else if($scope.articulosTabla.length === 0) { | 231 | } else if($scope.articulosTabla.length === 0) { |
231 | focaModalService.alert('Debe cargar al menos un articulo'); | 232 | focaModalService.alert('Debe cargar al menos un articulo'); |
232 | return; | 233 | return; |
233 | } | 234 | } |
234 | var date = new Date(); | 235 | var date = new Date(); |
235 | var remito = { | 236 | var remito = { |
236 | id: 0, | 237 | id: 0, |
237 | fechaCarga: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) | 238 | fechaCarga: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) |
238 | .toISOString().slice(0, 19).replace('T', ' '), | 239 | .toISOString().slice(0, 19).replace('T', ' '), |
239 | idVendedor: $scope.remito.vendedor.codigo, | 240 | idVendedor: $scope.remito.vendedor.codigo, |
240 | idCliente: $scope.remito.cliente.cod, | 241 | idCliente: $scope.remito.cliente.cod, |
241 | nombreCliente: $scope.remito.cliente.nom, | 242 | nombreCliente: $scope.remito.cliente.nom, |
242 | cuitCliente: $scope.remito.cliente.cuit, | 243 | cuitCliente: $scope.remito.cliente.cuit, |
243 | idProveedor: $scope.remito.proveedor.codigo, | 244 | idProveedor: $scope.remito.proveedor.codigo, |
244 | idDomicilio: $scope.remito.domicilio.id, | 245 | idDomicilio: $scope.remito.domicilio.id, |
245 | idCotizacion: $scope.remito.cotizacion.ID, | 246 | idCotizacion: $scope.remito.cotizacion.ID, |
246 | cotizacion: $scope.remito.cotizacion.COTIZACION, | 247 | cotizacion: $scope.remito.cotizacion.COTIZACION, |
247 | flete: $scope.remito.flete, | 248 | flete: $scope.remito.flete, |
248 | fob: $scope.remito.fob, | 249 | fob: $scope.remito.fob, |
249 | bomba: $scope.remito.bomba, | 250 | bomba: $scope.remito.bomba, |
250 | kilometros: $scope.remito.kilometros, | 251 | kilometros: $scope.remito.kilometros, |
251 | estado: 0, | 252 | estado: 0, |
252 | total: $scope.getTotal() | 253 | total: $scope.getTotal() |
253 | }; | 254 | }; |
254 | crearRemitoService.crearRemito(remito).then( | 255 | crearRemitoService.crearRemito(remito).then( |
255 | function(data) { | 256 | function(data) { |
256 | remitoBusinessService.addArticulos($scope.articulosTabla, | 257 | remitoBusinessService.addArticulos($scope.articulosTabla, |
257 | data.data.id, $scope.remito.cotizacion.COTIZACION); | 258 | data.data.id, $scope.remito.cotizacion.COTIZACION); |
258 | var plazos = $scope.plazosPagos; | 259 | var plazos = $scope.plazosPagos; |
259 | for(var j = 0; j < plazos.length; j++) { | 260 | for(var j = 0; j < plazos.length; j++) { |
260 | var json = { | 261 | var json = { |
261 | idRemito: data.data.id, | 262 | idRemito: data.data.id, |
262 | dias: plazos[j].dias | 263 | dias: plazos[j].dias |
263 | }; | 264 | }; |
264 | crearRemitoService.crearPlazosParaRemito(json); | 265 | crearRemitoService.crearPlazosParaRemito(json); |
265 | } | 266 | } |
266 | remitoBusinessService.addEstado(data.data.id, | 267 | remitoBusinessService.addEstado(data.data.id, |
267 | $scope.remito.vendedor.codigo); | 268 | $scope.remito.vendedor.codigo); |
268 | 269 | ||
269 | focaModalService.alert('Nota remito creada'); | 270 | focaModalService.alert('Nota remito creada'); |
270 | $scope.cabecera = []; | 271 | $scope.cabecera = []; |
271 | addCabecera('Moneda:', $scope.remito.moneda.detalle); | 272 | addCabecera('Moneda:', $scope.remito.moneda.detalle); |
272 | addCabecera( | 273 | addCabecera( |
273 | 'Fecha cotizacion:', | 274 | 'Fecha cotizacion:', |
274 | $filter('date')($scope.remito.cotizacion.FECHA, 'dd/MM/yyyy') | 275 | $filter('date')($scope.remito.cotizacion.FECHA, 'dd/MM/yyyy') |
275 | ); | 276 | ); |
276 | addCabecera('Cotizacion:', $scope.remito.cotizacion.COTIZACION); | 277 | addCabecera('Cotizacion:', $scope.remito.cotizacion.COTIZACION); |
277 | $scope.remito.vendedor = {}; | 278 | $scope.remito.vendedor = {}; |
278 | $scope.remito.cliente = {}; | 279 | $scope.remito.cliente = {}; |
279 | $scope.remito.proveedor = {}; | 280 | $scope.remito.proveedor = {}; |
280 | $scope.remito.domicilio = {}; | 281 | $scope.remito.domicilio = {}; |
281 | $scope.remito.flete = null; | 282 | $scope.remito.flete = null; |
282 | $scope.remito.fob = null; | 283 | $scope.remito.fob = null; |
283 | $scope.remito.bomba = null; | 284 | $scope.remito.bomba = null; |
284 | $scope.remito.kilometros = null; | 285 | $scope.remito.kilometros = null; |
285 | $scope.articulosTabla = []; | 286 | $scope.articulosTabla = []; |
286 | } | 287 | } |
287 | ); | 288 | ); |
288 | }; | 289 | }; |
289 | 290 | ||
290 | $scope.seleccionarArticulo = function() { | 291 | $scope.seleccionarArticulo = function() { |
291 | if ($scope.idLista === undefined) { | 292 | if ($scope.idLista === undefined) { |
292 | focaModalService.alert( | 293 | focaModalService.alert( |
293 | 'Primero seleccione una lista de precio y condicion'); | 294 | 'Primero seleccione una lista de precio y condicion'); |
294 | return; | 295 | return; |
295 | } | 296 | } |
296 | var modalInstance = $uibModal.open( | 297 | var modalInstance = $uibModal.open( |
297 | { | 298 | { |
298 | ariaLabelledBy: 'Busqueda de Productos', | 299 | ariaLabelledBy: 'Busqueda de Productos', |
299 | templateUrl: 'modal-busqueda-productos.html', | 300 | templateUrl: 'modal-busqueda-productos.html', |
300 | controller: 'modalBusquedaProductosCtrl', | 301 | controller: 'modalBusquedaProductosCtrl', |
301 | resolve: { | 302 | resolve: { |
302 | parametroProducto: { | 303 | parametroProducto: { |
303 | idLista: $scope.idLista, | 304 | idLista: $scope.idLista, |
304 | cotizacion: $scope.remito.cotizacion.COTIZACION, | 305 | cotizacion: $scope.remito.cotizacion.COTIZACION, |
305 | simbolo: $scope.remito.moneda.simbolo | 306 | simbolo: $scope.remito.moneda.simbolo |
306 | } | 307 | } |
307 | }, | 308 | }, |
308 | size: 'lg' | 309 | size: 'lg' |
309 | } | 310 | } |
310 | ); | 311 | ); |
311 | modalInstance.result.then( | 312 | modalInstance.result.then( |
312 | function(producto) { | 313 | function(producto) { |
313 | var newArt = | 314 | var newArt = |
314 | { | 315 | { |
315 | id: 0, | 316 | id: 0, |
316 | codigo: producto.codigo, | 317 | codigo: producto.codigo, |
317 | sector: producto.sector, | 318 | sector: producto.sector, |
318 | sectorCodigo: producto.sector + '-' + producto.codigo, | 319 | sectorCodigo: producto.sector + '-' + producto.codigo, |
319 | descripcion: producto.descripcion, | 320 | descripcion: producto.descripcion, |
320 | item: $scope.articulosTabla.length + 1, | 321 | item: $scope.articulosTabla.length + 1, |
321 | nombre: producto.descripcion, | 322 | nombre: producto.descripcion, |
322 | precio: parseFloat(producto.precio.toFixed(4)), | 323 | precio: parseFloat(producto.precio.toFixed(4)), |
323 | costoUnitario: producto.costo, | 324 | costoUnitario: producto.costo, |
324 | editCantidad: false, | 325 | editCantidad: false, |
325 | editPrecio: false | 326 | editPrecio: false |
326 | }; | 327 | }; |
327 | $scope.articuloACargar = newArt; | 328 | $scope.articuloACargar = newArt; |
328 | $scope.cargando = false; | 329 | $scope.cargando = false; |
329 | }, function() { | 330 | }, function() { |
330 | // funcion ejecutada cuando se cancela el modal | 331 | // funcion ejecutada cuando se cancela el modal |
331 | } | 332 | } |
332 | ); | 333 | ); |
333 | }; | 334 | }; |
334 | 335 | ||
335 | $scope.seleccionarVendedor = function() { | 336 | $scope.seleccionarVendedor = function() { |
336 | var modalInstance = $uibModal.open( | 337 | var modalInstance = $uibModal.open( |
337 | { | 338 | { |
338 | ariaLabelledBy: 'Busqueda de Vendedores', | 339 | ariaLabelledBy: 'Busqueda de Vendedores', |
339 | templateUrl: 'modal-vendedores.html', | 340 | templateUrl: 'modal-vendedores.html', |
340 | controller: 'modalVendedoresCtrl', | 341 | controller: 'modalVendedoresCtrl', |
341 | size: 'lg' | 342 | size: 'lg' |
342 | } | 343 | } |
343 | ); | 344 | ); |
344 | modalInstance.result.then( | 345 | modalInstance.result.then( |
345 | function(vendedor) { | 346 | function(vendedor) { |
346 | addCabecera('Vendedor:', vendedor.NomVen); | 347 | addCabecera('Vendedor:', vendedor.NomVen); |
347 | $scope.remito.vendedor.codigo = vendedor.CodVen; | 348 | $scope.remito.vendedor.codigo = vendedor.CodVen; |
348 | }, function() { | 349 | }, function() { |
349 | 350 | ||
350 | } | 351 | } |
351 | ); | 352 | ); |
352 | }; | 353 | }; |
353 | 354 | ||
354 | $scope.seleccionarProveedor = function() { | 355 | $scope.seleccionarProveedor = function() { |
355 | var modalInstance = $uibModal.open( | 356 | var modalInstance = $uibModal.open( |
356 | { | 357 | { |
357 | ariaLabelledBy: 'Busqueda de Proveedor', | 358 | ariaLabelledBy: 'Busqueda de Proveedor', |
358 | templateUrl: 'modal-proveedor.html', | 359 | templateUrl: 'modal-proveedor.html', |
359 | controller: 'focaModalProveedorCtrl', | 360 | controller: 'focaModalProveedorCtrl', |
360 | size: 'lg' | 361 | size: 'lg' |
361 | } | 362 | } |
362 | ); | 363 | ); |
363 | modalInstance.result.then( | 364 | modalInstance.result.then( |
364 | function(proveedor) { | 365 | function(proveedor) { |
365 | $scope.remito.proveedor.codigo = proveedor.COD; | 366 | $scope.remito.proveedor.codigo = proveedor.COD; |
366 | addCabecera('Proveedor:', proveedor.NOM); | 367 | addCabecera('Proveedor:', proveedor.NOM); |
367 | }, function() { | 368 | }, function() { |
368 | 369 | ||
369 | } | 370 | } |
370 | ); | 371 | ); |
371 | }; | 372 | }; |
372 | 373 | ||
373 | $scope.seleccionarCliente = function() { | 374 | $scope.seleccionarCliente = function() { |
374 | 375 | ||
375 | var modalInstance = $uibModal.open( | 376 | var modalInstance = $uibModal.open( |
376 | { | 377 | { |
377 | ariaLabelledBy: 'Busqueda de Cliente', | 378 | ariaLabelledBy: 'Busqueda de Cliente', |
378 | templateUrl: 'foca-busqueda-cliente-modal.html', | 379 | templateUrl: 'foca-busqueda-cliente-modal.html', |
379 | controller: 'focaBusquedaClienteModalController', | 380 | controller: 'focaBusquedaClienteModalController', |
380 | size: 'lg' | 381 | size: 'lg' |
381 | } | 382 | } |
382 | ); | 383 | ); |
383 | modalInstance.result.then( | 384 | modalInstance.result.then( |
384 | function(cliente) { | 385 | function(cliente) { |
385 | $scope.abrirModalDomicilios(cliente); | 386 | $scope.abrirModalDomicilios(cliente); |
386 | }, function() { | 387 | }, function() { |
387 | 388 | ||
388 | } | 389 | } |
389 | ); | 390 | ); |
390 | }; | 391 | }; |
391 | 392 | ||
392 | $scope.abrirModalDomicilios = function(cliente) { | 393 | $scope.abrirModalDomicilios = function(cliente) { |
393 | var modalInstanceDomicilio = $uibModal.open( | 394 | var modalInstanceDomicilio = $uibModal.open( |
394 | { | 395 | { |
395 | ariaLabelledBy: 'Busqueda de Domicilios', | 396 | ariaLabelledBy: 'Busqueda de Domicilios', |
396 | templateUrl: 'modal-domicilio.html', | 397 | templateUrl: 'modal-domicilio.html', |
397 | controller: 'focaModalDomicilioController', | 398 | controller: 'focaModalDomicilioController', |
398 | resolve: { idCliente: function() { return cliente.cod; }}, | 399 | resolve: { idCliente: function() { return cliente.cod; }}, |
399 | size: 'lg', | 400 | size: 'lg', |
400 | } | 401 | } |
401 | ); | 402 | ); |
402 | modalInstanceDomicilio.result.then( | 403 | modalInstanceDomicilio.result.then( |
403 | function(domicilio) { | 404 | function(domicilio) { |
404 | $scope.remito.domicilio.id = domicilio.nivel2; | 405 | $scope.remito.domicilio.id = domicilio.nivel2; |
405 | $scope.remito.cliente = cliente; | 406 | $scope.remito.cliente = cliente; |
406 | 407 | ||
407 | addCabecera('Cliente:', cliente.nom); | 408 | addCabecera('Cliente:', cliente.nom); |
408 | addCabecera('Domicilio:', domicilio.dom); | 409 | addCabecera('Domicilio:', domicilio.dom); |
409 | }, function() { | 410 | }, function() { |
410 | $scope.seleccionarCliente(); | 411 | $scope.seleccionarCliente(); |
411 | return; | 412 | return; |
412 | } | 413 | } |
413 | ); | 414 | ); |
414 | }; | 415 | }; |
415 | 416 | ||
416 | $scope.mostrarFichaCliente = function() { | 417 | $scope.mostrarFichaCliente = function() { |
417 | $uibModal.open( | 418 | $uibModal.open( |
418 | { | 419 | { |
419 | ariaLabelledBy: 'Datos del Cliente', | 420 | ariaLabelledBy: 'Datos del Cliente', |
420 | templateUrl: 'foca-crear-remito-ficha-cliente.html', | 421 | templateUrl: 'foca-crear-remito-ficha-cliente.html', |
421 | controller: 'focaCrearRemitoFichaClienteController', | 422 | controller: 'focaCrearRemitoFichaClienteController', |
422 | size: 'lg' | 423 | size: 'lg' |
423 | } | 424 | } |
424 | ); | 425 | ); |
425 | }; | 426 | }; |
426 | 427 | ||
427 | $scope.getTotal = function() { | 428 | $scope.getTotal = function() { |
428 | var total = 0; | 429 | var total = 0; |
429 | var arrayTempArticulos = $scope.articulosTabla; | 430 | var arrayTempArticulos = $scope.articulosTabla; |
430 | for (var i = 0; i < arrayTempArticulos.length; i++) { | 431 | for (var i = 0; i < arrayTempArticulos.length; i++) { |
431 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; | 432 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; |
432 | } | 433 | } |
433 | return parseFloat(total.toFixed(2)); | 434 | return parseFloat(total.toFixed(2)); |
434 | }; | 435 | }; |
435 | 436 | ||
436 | $scope.getSubTotal = function() { | 437 | $scope.getSubTotal = function() { |
437 | if($scope.articuloACargar) { | 438 | if($scope.articuloACargar) { |
438 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; | 439 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; |
439 | } | 440 | } |
440 | }; | 441 | }; |
441 | 442 | ||
442 | $scope.abrirModalListaPrecio = function() { | 443 | $scope.abrirModalListaPrecio = function() { |
443 | var modalInstance = $uibModal.open( | 444 | var modalInstance = $uibModal.open( |
444 | { | 445 | { |
445 | ariaLabelledBy: 'Busqueda de Precio Condición', | 446 | ariaLabelledBy: 'Busqueda de Precio Condición', |
446 | templateUrl: 'modal-precio-condicion.html', | 447 | templateUrl: 'modal-precio-condicion.html', |
447 | controller: 'focaModalPrecioCondicionController', | 448 | controller: 'focaModalPrecioCondicionController', |
448 | size: 'lg' | 449 | size: 'lg' |
449 | } | 450 | } |
450 | ); | 451 | ); |
451 | modalInstance.result.then( | 452 | modalInstance.result.then( |
452 | function(precioCondicion) { | 453 | function(precioCondicion) { |
453 | var cabecera = ''; | 454 | var cabecera = ''; |
454 | var plazosConcat = ''; | 455 | var plazosConcat = ''; |
455 | if(!Array.isArray(precioCondicion)) { | 456 | if(!Array.isArray(precioCondicion)) { |
456 | $scope.plazosPagos = precioCondicion.plazoPago; | 457 | $scope.plazosPagos = precioCondicion.plazoPago; |
457 | $scope.idLista = precioCondicion.idListaPrecio; | 458 | $scope.idLista = precioCondicion.idListaPrecio; |
458 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { | 459 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { |
459 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; | 460 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; |
460 | } | 461 | } |
461 | cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); | 462 | cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); |
462 | } else { //Cuando se ingresan los plazos manualmente | 463 | } else { //Cuando se ingresan los plazos manualmente |
463 | $scope.idLista = -1; //-1, el modal productos busca todos los productos | 464 | $scope.idLista = -1; //-1, el modal productos busca todos los productos |
464 | $scope.plazosPagos = precioCondicion; | 465 | $scope.plazosPagos = precioCondicion; |
465 | for(var j = 0; j < precioCondicion.length; j++) { | 466 | for(var j = 0; j < precioCondicion.length; j++) { |
466 | plazosConcat += precioCondicion[j].dias + ' '; | 467 | plazosConcat += precioCondicion[j].dias + ' '; |
467 | } | 468 | } |
468 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); | 469 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); |
469 | } | 470 | } |
470 | $scope.articulosTabla = []; | 471 | $scope.articulosTabla = []; |
471 | addCabecera('Precios y condiciones:', cabecera); | 472 | addCabecera('Precios y condiciones:', cabecera); |
472 | }, function() { | 473 | }, function() { |
473 | 474 | ||
474 | } | 475 | } |
475 | ); | 476 | ); |
476 | }; | 477 | }; |
477 | 478 | ||
478 | $scope.abrirModalFlete = function() { | 479 | $scope.abrirModalFlete = function() { |
479 | var modalInstance = $uibModal.open( | 480 | var modalInstance = $uibModal.open( |
480 | { | 481 | { |
481 | ariaLabelledBy: 'Busqueda de Flete', | 482 | ariaLabelledBy: 'Busqueda de Flete', |
482 | templateUrl: 'modal-flete.html', | 483 | templateUrl: 'modal-flete.html', |
483 | controller: 'focaModalFleteController', | 484 | controller: 'focaModalFleteController', |
484 | size: 'lg', | 485 | size: 'lg', |
485 | resolve: { | 486 | resolve: { |
486 | parametrosFlete: | 487 | parametrosFlete: |
487 | function() { | 488 | function() { |
488 | return { | 489 | return { |
489 | flete: $scope.remito.flete ? '1' : | 490 | flete: $scope.remito.flete ? '1' : |
490 | ($scope.remito.fob ? 'FOB' : | 491 | ($scope.remito.fob ? 'FOB' : |
491 | ($scope.remito.flete === undefined ? null : '0')), | 492 | ($scope.remito.flete === undefined ? null : '0')), |
492 | bomba: $scope.remito.bomba ? '1' : | 493 | bomba: $scope.remito.bomba ? '1' : |
493 | ($scope.remito.bomba === undefined ? null : '0'), | 494 | ($scope.remito.bomba === undefined ? null : '0'), |
494 | kilometros: $scope.remito.kilometros | 495 | kilometros: $scope.remito.kilometros |
495 | }; | 496 | }; |
496 | } | 497 | } |
497 | } | 498 | } |
498 | } | 499 | } |
499 | ); | 500 | ); |
500 | modalInstance.result.then( | 501 | modalInstance.result.then( |
501 | function(datos) { | 502 | function(datos) { |
502 | $scope.remito.flete = datos.flete; | 503 | $scope.remito.flete = datos.flete; |
503 | $scope.remito.fob = datos.FOB; | 504 | $scope.remito.fob = datos.FOB; |
504 | $scope.remito.bomba = datos.bomba; | 505 | $scope.remito.bomba = datos.bomba; |
505 | $scope.remito.kilometros = datos.kilometros; | 506 | $scope.remito.kilometros = datos.kilometros; |
506 | 507 | ||
507 | addCabecera('Flete:', datos.flete ? 'Si' : | 508 | addCabecera('Flete:', datos.flete ? 'Si' : |
508 | ($scope.remito.fob ? 'FOB' : 'No')); | 509 | ($scope.remito.fob ? 'FOB' : 'No')); |
509 | if(datos.flete) { | 510 | if(datos.flete) { |
510 | addCabecera('Bomba:', datos.bomba ? 'Si' : 'No'); | 511 | addCabecera('Bomba:', datos.bomba ? 'Si' : 'No'); |
511 | addCabecera('Kilometros:', datos.kilometros); | 512 | addCabecera('Kilometros:', datos.kilometros); |
512 | } else { | 513 | } else { |
513 | removeCabecera('Bomba:'); | 514 | removeCabecera('Bomba:'); |
514 | removeCabecera('Kilometros:'); | 515 | removeCabecera('Kilometros:'); |
515 | $scope.remito.fob = false; | 516 | $scope.remito.fob = false; |
516 | $scope.remito.bomba = false; | 517 | $scope.remito.bomba = false; |
517 | $scope.remito.kilometros = null; | 518 | $scope.remito.kilometros = null; |
518 | } | 519 | } |
519 | }, function() { | 520 | }, function() { |
520 | 521 | ||
521 | } | 522 | } |
522 | ); | 523 | ); |
523 | }; | 524 | }; |
524 | 525 | ||
525 | $scope.abrirModalMoneda = function() { | 526 | $scope.abrirModalMoneda = function() { |
526 | var modalInstance = $uibModal.open( | 527 | var modalInstance = $uibModal.open( |
527 | { | 528 | { |
528 | ariaLabelledBy: 'Busqueda de Moneda', | 529 | ariaLabelledBy: 'Busqueda de Moneda', |
529 | templateUrl: 'modal-moneda.html', | 530 | templateUrl: 'modal-moneda.html', |
530 | controller: 'focaModalMonedaController', | 531 | controller: 'focaModalMonedaController', |
531 | size: 'lg' | 532 | size: 'lg' |
532 | } | 533 | } |
533 | ); | 534 | ); |
534 | modalInstance.result.then( | 535 | modalInstance.result.then( |
535 | function(moneda) { | 536 | function(moneda) { |
536 | $scope.abrirModalCotizacion(moneda); | 537 | $scope.abrirModalCotizacion(moneda); |
537 | }, function() { | 538 | }, function() { |
538 | 539 | ||
539 | } | 540 | } |
540 | ); | 541 | ); |
541 | }; | 542 | }; |
542 | 543 | ||
543 | $scope.abrirModalCotizacion = function(moneda) { | 544 | $scope.abrirModalCotizacion = function(moneda) { |
544 | var modalInstance = $uibModal.open( | 545 | var modalInstance = $uibModal.open( |
545 | { | 546 | { |
546 | ariaLabelledBy: 'Busqueda de Cotización', | 547 | ariaLabelledBy: 'Busqueda de Cotización', |
547 | templateUrl: 'modal-cotizacion.html', | 548 | templateUrl: 'modal-cotizacion.html', |
548 | controller: 'focaModalCotizacionController', | 549 | controller: 'focaModalCotizacionController', |
549 | size: 'lg', | 550 | size: 'lg', |
550 | resolve: {idMoneda: function() {return moneda.ID;}} | 551 | resolve: {idMoneda: function() {return moneda.ID;}} |
551 | } | 552 | } |
552 | ); | 553 | ); |
553 | modalInstance.result.then( | 554 | modalInstance.result.then( |
554 | function(cotizacion) { | 555 | function(cotizacion) { |
555 | var articulosTablaTemp = $scope.articulosTabla; | 556 | var articulosTablaTemp = $scope.articulosTabla; |
556 | for(var i = 0; i < articulosTablaTemp.length; i++) { | 557 | for(var i = 0; i < articulosTablaTemp.length; i++) { |
557 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * | 558 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * |
558 | $scope.remito.cotizacion.COTIZACION; | 559 | $scope.remito.cotizacion.COTIZACION; |
559 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / | 560 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / |
560 | cotizacion.COTIZACION; | 561 | cotizacion.COTIZACION; |
561 | } | 562 | } |
562 | $scope.articulosTabla = articulosTablaTemp; | 563 | $scope.articulosTabla = articulosTablaTemp; |
563 | $scope.remito.moneda = { | 564 | $scope.remito.moneda = { |
564 | id: moneda.ID, | 565 | id: moneda.ID, |
565 | detalle: moneda.DETALLE, | 566 | detalle: moneda.DETALLE, |
566 | simbolo: moneda.SIMBOLO | 567 | simbolo: moneda.SIMBOLO |
567 | }; | 568 | }; |
568 | $scope.remito.cotizacion = { | 569 | $scope.remito.cotizacion = { |
569 | ID: cotizacion.ID, | 570 | ID: cotizacion.ID, |
570 | COTIZACION: cotizacion.COTIZACION, | 571 | COTIZACION: cotizacion.COTIZACION, |
571 | FECHA: cotizacion.FECHA | 572 | FECHA: cotizacion.FECHA |
572 | }; | 573 | }; |
573 | addCabecera('Moneda:', moneda.DETALLE); | 574 | addCabecera('Moneda:', moneda.DETALLE); |
574 | addCabecera( | 575 | addCabecera( |
575 | 'Fecha cotizacion:', | 576 | 'Fecha cotizacion:', |
576 | $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') | 577 | $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') |
577 | ); | 578 | ); |
578 | addCabecera('Cotizacion:', cotizacion.COTIZACION); | 579 | addCabecera('Cotizacion:', cotizacion.COTIZACION); |
579 | }, function() { | 580 | }, function() { |
580 | 581 | ||
581 | } | 582 | } |
582 | ); | 583 | ); |
583 | }; | 584 | }; |
584 | 585 | ||
585 | $scope.agregarATabla = function(key) { | 586 | $scope.agregarATabla = function(key) { |
586 | if(key === 13) { | 587 | if(key === 13) { |
587 | if($scope.articuloACargar.cantidad === undefined || | 588 | if($scope.articuloACargar.cantidad === undefined || |
588 | $scope.articuloACargar.cantidad === 0 || | 589 | $scope.articuloACargar.cantidad === 0 || |
589 | $scope.articuloACargar.cantidad === null ){ | 590 | $scope.articuloACargar.cantidad === null ){ |
590 | focaModalService.alert('El valor debe ser al menos 1'); | 591 | focaModalService.alert('El valor debe ser al menos 1'); |
591 | return; | 592 | return; |
592 | } | 593 | } |
593 | delete $scope.articuloACargar.sectorCodigo; | 594 | delete $scope.articuloACargar.sectorCodigo; |
594 | $scope.articulosTabla.push($scope.articuloACargar); | 595 | $scope.articulosTabla.push($scope.articuloACargar); |
595 | $scope.cargando = true; | 596 | $scope.cargando = true; |
596 | } | 597 | } |
597 | }; | 598 | }; |
598 | 599 | ||
599 | $scope.quitarArticulo = function(key) { | 600 | $scope.quitarArticulo = function(key) { |
600 | $scope.articulosTabla.splice(key, 1); | 601 | $scope.articulosTabla.splice(key, 1); |
601 | }; | 602 | }; |
602 | 603 | ||
603 | $scope.editarArticulo = function(key, articulo) { | 604 | $scope.editarArticulo = function(key, articulo) { |
604 | if(key === 13) { | 605 | if(key === 13) { |
605 | if(articulo.cantidad === null || articulo.cantidad === 0 || | 606 | if(articulo.cantidad === null || articulo.cantidad === 0 || |
606 | articulo.cantidad === undefined){ | 607 | articulo.cantidad === undefined){ |
607 | focaModalService.alert('El valor debe ser al menos 1'); | 608 | focaModalService.alert('El valor debe ser al menos 1'); |
608 | return; | 609 | return; |
609 | } | 610 | } |
610 | articulo.editCantidad = false; | 611 | articulo.editCantidad = false; |
611 | articulo.editPrecio = false; | 612 | articulo.editPrecio = false; |
612 | } | 613 | } |
613 | }; | 614 | }; |
614 | 615 | ||
615 | $scope.cambioEdit = function(articulo, propiedad) { | 616 | $scope.cambioEdit = function(articulo, propiedad) { |
616 | if(propiedad === 'cantidad') { | 617 | if(propiedad === 'cantidad') { |
617 | articulo.editCantidad = true; | 618 | articulo.editCantidad = true; |
618 | } else if(propiedad === 'precio') { | 619 | } else if(propiedad === 'precio') { |
619 | articulo.editPrecio = true; | 620 | articulo.editPrecio = true; |
620 | } | 621 | } |
621 | }; | 622 | }; |
622 | 623 | ||
623 | $scope.limpiarFlete = function() { | 624 | $scope.limpiarFlete = function() { |
624 | $scope.remito.fleteNombre = ''; | 625 | $scope.remito.fleteNombre = ''; |
625 | $scope.remito.chofer = ''; | 626 | $scope.remito.chofer = ''; |
626 | $scope.remito.vehiculo = ''; | 627 | $scope.remito.vehiculo = ''; |
627 | $scope.remito.kilometros = ''; | 628 | $scope.remito.kilometros = ''; |
628 | $scope.remito.costoUnitarioKmFlete = ''; | 629 | $scope.remito.costoUnitarioKmFlete = ''; |
629 | $scope.choferes = ''; | 630 | $scope.choferes = ''; |
630 | $scope.vehiculos = ''; | 631 | $scope.vehiculos = ''; |
631 | }; | 632 | }; |
632 | 633 | ||
633 | $scope.limpiarPantalla = function() { | 634 | $scope.limpiarPantalla = function() { |
634 | $scope.limpiarFlete(); | 635 | $scope.limpiarFlete(); |
635 | $scope.remito.flete = '0'; | 636 | $scope.remito.flete = '0'; |
636 | $scope.remito.bomba = '0'; | 637 | $scope.remito.bomba = '0'; |
637 | $scope.remito.precioCondicion = ''; | 638 | $scope.remito.precioCondicion = ''; |
638 | $scope.articulosTabla = []; | 639 | $scope.articulosTabla = []; |
639 | $scope.remito.vendedor.nombre = ''; | 640 | $scope.remito.vendedor.nombre = ''; |
640 | $scope.remito.cliente = {nombre: ''}; | 641 | $scope.remito.cliente = {nombre: ''}; |
641 | $scope.remito.domicilio = {dom: ''}; | 642 | $scope.remito.domicilio = {dom: ''}; |
642 | $scope.domiciliosCliente = []; | 643 | $scope.domiciliosCliente = []; |
643 | }; | 644 | }; |
644 | 645 | ||
645 | $scope.resetFilter = function() { | 646 | $scope.resetFilter = function() { |
646 | $scope.articuloACargar = {}; | 647 | $scope.articuloACargar = {}; |
647 | $scope.cargando = true; | 648 | $scope.cargando = true; |
648 | }; | 649 | }; |
649 | 650 | ||
650 | $scope.selectFocus = function($event) { | 651 | $scope.selectFocus = function($event) { |
651 | $event.target.select(); | 652 | $event.target.select(); |
652 | }; | 653 | }; |
653 | 654 | ||
654 | $scope.salir = function() { | 655 | $scope.salir = function() { |
655 | $location.path('/'); | 656 | $location.path('/'); |
656 | }; | 657 | }; |
657 | 658 | ||
658 | function addCabecera(label, valor) { | 659 | function addCabecera(label, valor) { |
659 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); | 660 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); |
660 | if(propiedad.length === 1) { | 661 | if(propiedad.length === 1) { |
661 | propiedad[0].valor = valor; | 662 | propiedad[0].valor = valor; |
662 | } else { | 663 | } else { |
663 | $scope.cabecera.push({label: label, valor: valor}); | 664 | $scope.cabecera.push({label: label, valor: valor}); |
664 | } | 665 | } |
665 | } | 666 | } |
666 | 667 | ||
667 | function removeCabecera(label) { | 668 | function removeCabecera(label) { |
668 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); | 669 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); |
669 | if(propiedad.length === 1){ | 670 | if(propiedad.length === 1){ |
670 | $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); | 671 | $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); |
671 | } | 672 | } |
672 | } | 673 | } |
673 | 674 | ||
674 | function rellenar(relleno, longitud) { | 675 | function rellenar(relleno, longitud) { |
675 | relleno = '' + relleno; | 676 | relleno = '' + relleno; |
676 | while (relleno.length < longitud) { | 677 | while (relleno.length < longitud) { |
677 | relleno = '0' + relleno; | 678 | relleno = '0' + relleno; |
678 | } | 679 | } |
679 | 680 | ||
680 | return relleno; | 681 | return relleno; |
681 | } | 682 | } |
682 | } | 683 | } |
683 | ] | 684 | ] |
684 | ) | 685 | ) |
685 | .controller('remitoListaCtrl', [ | 686 | .controller('remitoListaCtrl', [ |
686 | '$scope', | 687 | '$scope', |
687 | 'crearRemitoService', | 688 | 'crearRemitoService', |
688 | '$location', | 689 | '$location', |
689 | function($scope, crearRemitoService, $location) { | 690 | function($scope, crearRemitoService, $location) { |
690 | crearRemitoService.obtenerRemito().then(function(datos) { | 691 | crearRemitoService.obtenerRemito().then(function(datos) { |
691 | $scope.remitos = datos.data; | 692 | $scope.remitos = datos.data; |
692 | }); | 693 | }); |
693 | $scope.editar = function(remito) { | 694 | $scope.editar = function(remito) { |
694 | crearRemitoService.setRemito(remito); | 695 | crearRemitoService.setRemito(remito); |
695 | $location.path('/venta-nota-remito/abm/'); | 696 | $location.path('/venta-nota-remito/abm/'); |
696 | }; | 697 | }; |
697 | $scope.crearRemito = function() { | 698 | $scope.crearRemito = function() { |
698 | crearRemitoService.clearRemito(); | 699 | crearRemitoService.clearRemito(); |
699 | $location.path('/venta-nota-remito/abm/'); | 700 | $location.path('/venta-nota-remito/abm/'); |
700 | }; | 701 | }; |
701 | } | 702 | } |
702 | ]) | 703 | ]) |
703 | .controller('focaCrearRemitoFichaClienteController', [ | 704 | .controller('focaCrearRemitoFichaClienteController', [ |
704 | '$scope', | 705 | '$scope', |
705 | 'crearRemitoService', | 706 | 'crearRemitoService', |
706 | '$location', | 707 | '$location', |
707 | function($scope, crearRemitoService, $location) { | 708 | function($scope, crearRemitoService, $location) { |
708 | crearRemitoService.obtenerRemito().then(function(datos) { | 709 | crearRemitoService.obtenerRemito().then(function(datos) { |
709 | $scope.remitos = datos.data; | 710 | $scope.remitos = datos.data; |
710 | }); | 711 | }); |
711 | $scope.editar = function(remito) { | 712 | $scope.editar = function(remito) { |
712 | crearRemitoService.setRemito(remito); | 713 | crearRemitoService.setRemito(remito); |
713 | $location.path('/venta-nota-remito/abm/'); | 714 | $location.path('/venta-nota-remito/abm/'); |
714 | }; | 715 | }; |
715 | $scope.crearRemito = function() { | 716 | $scope.crearRemito = function() { |
716 | crearRemitoService.clearRemito(); | 717 | crearRemitoService.clearRemito(); |
717 | $location.path('/venta-nota-remito/abm/'); | 718 | $location.path('/venta-nota-remito/abm/'); |
718 | }; | 719 | }; |
719 | } | 720 | } |
720 | ]); | 721 | ]); |
721 | 722 |