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