Commit 351c88d9d1d66410c046b2ed4c6a9b1e9e18e641
Exists in
master
and in
1 other branch
Merge remote-tracking branch 'upstream/develop'
Showing
2 changed files
Show diff stats
src/js/controller.js
1 | angular.module('focaCrearRemito') .controller('remitoController', | 1 | angular.module('focaCrearRemito') .controller('remitoController', |
2 | [ | 2 | [ |
3 | '$scope', '$uibModal', '$location', '$filter', 'crearRemitoService', '$timeout', | 3 | '$scope', '$uibModal', '$location', '$filter', 'crearRemitoService', '$timeout', |
4 | 'focaModalService', 'remitoBusinessService', '$rootScope', 'focaBotoneraLateralService', | 4 | 'focaModalService', 'remitoBusinessService', '$rootScope', 'focaBotoneraLateralService', |
5 | '$localStorage', | 5 | '$localStorage', |
6 | function( | 6 | function( |
7 | $scope, $uibModal, $location, $filter, crearRemitoService, $timeout, focaModalService, | 7 | $scope, $uibModal, $location, $filter, crearRemitoService, $timeout, focaModalService, |
8 | remitoBusinessService, $rootScope, focaBotoneraLateralService, $localStorage) | 8 | remitoBusinessService, $rootScope, focaBotoneraLateralService, $localStorage) |
9 | { | 9 | { |
10 | config(); | 10 | config(); |
11 | 11 | ||
12 | function config() { | 12 | function config() { |
13 | $scope.tmpCantidad = Number; | 13 | $scope.tmpCantidad = Number; |
14 | $scope.tmpPrecio = Number; | 14 | $scope.tmpPrecio = Number; |
15 | $scope.botonera = crearRemitoService.getBotonera(); | 15 | $scope.botonera = crearRemitoService.getBotonera(); |
16 | $scope.isNumber = angular.isNumber; | 16 | $scope.isNumber = angular.isNumber; |
17 | $scope.datepickerAbierto = false; | 17 | $scope.datepickerAbierto = false; |
18 | $scope.show = false; | 18 | $scope.show = false; |
19 | $scope.cargando = true; | 19 | $scope.cargando = true; |
20 | $scope.now = new Date(); | 20 | $scope.now = new Date(); |
21 | $scope.puntoVenta = rellenar(0, 4); | 21 | $scope.puntoVenta = rellenar(0, 4); |
22 | $scope.comprobante = rellenar(0, 8); | 22 | $scope.comprobante = rellenar(0, 8); |
23 | $scope.dateOptions = { | 23 | $scope.dateOptions = { |
24 | maxDate: new Date(), | 24 | maxDate: new Date(), |
25 | minDate: new Date(2010, 0, 1) | 25 | minDate: new Date(2010, 0, 1) |
26 | }; | 26 | }; |
27 | 27 | ||
28 | var monedaPorDefecto; | 28 | var monedaPorDefecto; |
29 | var proveedorPorDefecto; | 29 | var proveedorPorDefecto; |
30 | var promiseMoneda = crearRemitoService.getCotizacionByIdMoneda(1); | 30 | var promiseMoneda = crearRemitoService.getCotizacionByIdMoneda(1); |
31 | var promiseProveedor = crearRemitoService.getProveedorById(98); | 31 | var promiseProveedor = crearRemitoService.getProveedorById(98); |
32 | 32 | ||
33 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' | 33 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' |
34 | //Trabajo con el proveedo YPF, por eso uso siempre la primera | 34 | //Trabajo con el proveedo YPF, por eso uso siempre la primera |
35 | 35 | ||
36 | Promise.all([promiseMoneda, promiseProveedor]).then(function(res) { | 36 | Promise.all([promiseMoneda, promiseProveedor]).then(function(res) { |
37 | 37 | ||
38 | monedaPorDefecto = res[0].data[0]; | 38 | monedaPorDefecto = res[0].data[0]; |
39 | proveedorPorDefecto = res[1].data[0]; | 39 | proveedorPorDefecto = res[1].data[0]; |
40 | 40 | ||
41 | $scope.remito.cotizacion = Object.assign( | 41 | $scope.remito.cotizacion = Object.assign( |
42 | {moneda: monedaPorDefecto}, | 42 | {moneda: monedaPorDefecto}, |
43 | monedaPorDefecto.cotizaciones[0] | 43 | monedaPorDefecto.cotizaciones[0] |
44 | ); | 44 | ); |
45 | $scope.inicial.cotizacion = $scope.remito.cotizacion; | 45 | $scope.inicial.cotizacion = $scope.remito.cotizacion; |
46 | 46 | ||
47 | 47 | ||
48 | $scope.remito.proveedor = Object.assign( | 48 | $scope.remito.proveedor = Object.assign( |
49 | {proveedor: proveedorPorDefecto} | 49 | {proveedor: proveedorPorDefecto} |
50 | ); | 50 | ); |
51 | $scope.inicial.proveedor = $scope.remito.proveedor; | 51 | $scope.inicial.proveedor = $scope.remito.proveedor; |
52 | 52 | ||
53 | $scope.cotizacionPorDefecto = angular.copy($scope.remito.cotizacion); | 53 | $scope.cotizacionPorDefecto = angular.copy($scope.remito.cotizacion); |
54 | $scope.proveedor = angular.copy($scope.remito.proveedor); | 54 | $scope.proveedor = angular.copy($scope.remito.proveedor); |
55 | 55 | ||
56 | $scope.remito.flete = false; | 56 | $scope.remito.flete = false; |
57 | $scope.remito.fob = false; | 57 | $scope.remito.fob = false; |
58 | $scope.remito.bomba = false; | 58 | $scope.remito.bomba = false; |
59 | 59 | ||
60 | $timeout(function() {getLSRemito();}); | 60 | $scope.inicial.flete = false; |
61 | $scope.inicial.fob = false; | ||
62 | $scope.inicial.bomba = false; | ||
63 | |||
64 | $timeout(function() { getLSRemito(); }); | ||
61 | }); | 65 | }); |
62 | //SETEO BOTONERA LATERAL | 66 | //SETEO BOTONERA LATERAL |
63 | $timeout(function() { | 67 | $timeout(function() { |
64 | focaBotoneraLateralService.showSalir(false); | 68 | focaBotoneraLateralService.showSalir(false); |
65 | focaBotoneraLateralService.showPausar(true); | 69 | focaBotoneraLateralService.showPausar(true); |
66 | focaBotoneraLateralService.showGuardar(true, $scope.crearRemito); | 70 | focaBotoneraLateralService.showGuardar(true, $scope.crearRemito); |
67 | focaBotoneraLateralService.addCustomButton('Salir', salir); | 71 | focaBotoneraLateralService.addCustomButton('Salir', salir); |
68 | }); | 72 | }); |
69 | 73 | ||
70 | init(); | 74 | init(); |
71 | 75 | ||
72 | } | 76 | } |
73 | 77 | ||
74 | function init() { | 78 | function init() { |
75 | $scope.$broadcast('cleanCabecera'); | 79 | $scope.$broadcast('cleanCabecera'); |
76 | 80 | ||
77 | $scope.remito = { | 81 | $scope.remito = { |
78 | id: 0, | 82 | id: 0, |
79 | estado: 0, | 83 | estado: 0, |
80 | vendedor: {}, | 84 | vendedor: {}, |
81 | cliente: {}, | 85 | cliente: {}, |
82 | proveedor: {}, | 86 | proveedor: {}, |
83 | domicilio: {dom: ''}, | 87 | domicilio: {dom: ''}, |
84 | moneda: {}, | 88 | moneda: {}, |
85 | cotizacion: $scope.cotizacionPorDefecto || {}, | 89 | cotizacion: $scope.cotizacionPorDefecto || {}, |
86 | articulosRemito: [] | 90 | articulosRemito: [] |
87 | }; | 91 | }; |
88 | 92 | ||
89 | $scope.notaPedido = { | 93 | $scope.notaPedido = { |
90 | id: 0 | 94 | id: 0 |
91 | }; | 95 | }; |
92 | 96 | ||
93 | $scope.remito.articulosRemito = []; | 97 | $scope.remito.articulosRemito = []; |
94 | $scope.idLista = undefined; | 98 | $scope.idLista = undefined; |
95 | 99 | ||
96 | crearRemitoService.getNumeroRemito().then( | 100 | crearRemitoService.getNumeroRemito().then( |
97 | function(res) { | 101 | function(res) { |
98 | $scope.puntoVenta = rellenar(res.data.sucursal, 4); | 102 | $scope.puntoVenta = rellenar(res.data.sucursal, 4); |
99 | $scope.comprobante = rellenar(res.data.numeroRemito, 8); | 103 | $scope.comprobante = rellenar(res.data.numeroRemito, 8); |
100 | }, | 104 | }, |
101 | function(err) { | 105 | function(err) { |
102 | focaModalService.alert('La terminal no esta configurada correctamente'); | 106 | focaModalService.alert('La terminal no esta configurada correctamente'); |
103 | console.info(err); | 107 | console.info(err); |
104 | } | 108 | } |
105 | ); | 109 | ); |
106 | 110 | ||
107 | $scope.inicial = angular.copy($scope.remito); | 111 | $scope.inicial = angular.copy($scope.remito); |
108 | } | 112 | } |
109 | 113 | ||
110 | $scope.$watch('remito', function(newValue) { | 114 | $scope.$watch('remito', function(newValue) { |
111 | focaBotoneraLateralService.setPausarData({ | 115 | focaBotoneraLateralService.setPausarData({ |
112 | label: 'remito', | 116 | label: 'remito', |
113 | val: newValue | 117 | val: newValue |
114 | }); | 118 | }); |
115 | }, true); | 119 | }, true); |
116 | 120 | ||
117 | $scope.seleccionarNotaPedido = function() { | 121 | $scope.seleccionarNotaPedido = function() { |
118 | if (varlidarRemitoFacturado()) { | 122 | if (varlidarRemitoFacturado()) { |
119 | var modalInstance = $uibModal.open( | 123 | var modalInstance = $uibModal.open( |
120 | { | 124 | { |
121 | ariaLabelledBy: 'Busqueda de Nota de Pedido', | 125 | ariaLabelledBy: 'Busqueda de Nota de Pedido', |
122 | templateUrl: 'foca-modal-nota-pedido.html', | 126 | templateUrl: 'foca-modal-nota-pedido.html', |
123 | controller: 'focaModalNotaPedidoController', | 127 | controller: 'focaModalNotaPedidoController', |
124 | size: 'lg', | 128 | size: 'lg', |
125 | resolve: { | 129 | resolve: { |
126 | usadoPor: function() { return 'remito'; }, | 130 | usadoPor: function() { return 'remito'; }, |
127 | idVendedor: function() { return null; } | 131 | idVendedor: function() { return null; } |
128 | } | 132 | } |
129 | } | 133 | } |
130 | ); | 134 | ); |
131 | modalInstance.result.then( | 135 | modalInstance.result.then( |
132 | function(notaPedido) { | 136 | function(notaPedido) { |
133 | //añado cabeceras | 137 | //añado cabeceras |
134 | $scope.notaPedido.id = notaPedido.id; | 138 | $scope.notaPedido.id = notaPedido.id; |
135 | $scope.$broadcast('removeCabecera', 'Bomba:'); | 139 | $scope.$broadcast('removeCabecera', 'Bomba:'); |
136 | $scope.$broadcast('removeCabecera', 'Kilometros:'); | 140 | $scope.$broadcast('removeCabecera', 'Kilometros:'); |
137 | var puntosDescarga = []; | 141 | var puntosDescarga = []; |
138 | notaPedido.notaPedidoPuntoDescarga.forEach(function(notaPedido) { | 142 | notaPedido.notaPedidoPuntoDescarga.forEach(function(notaPedido) { |
139 | puntosDescarga.push(notaPedido.puntoDescarga); | 143 | puntosDescarga.push(notaPedido.puntoDescarga); |
140 | }); | 144 | }); |
141 | var cabeceras = [ | 145 | var cabeceras = [ |
142 | { | 146 | { |
143 | label: 'Moneda:', | 147 | label: 'Moneda:', |
144 | valor: notaPedido.cotizacion.moneda.DETALLE | 148 | valor: notaPedido.cotizacion.moneda.DETALLE |
145 | }, | 149 | }, |
146 | { | 150 | { |
147 | label: 'Fecha cotizacion:', | 151 | label: 'Fecha cotizacion:', |
148 | valor: $filter('date')(notaPedido.cotizacion.FECHA, | 152 | valor: $filter('date')(notaPedido.cotizacion.FECHA, |
149 | 'dd/MM/yyyy') | 153 | 'dd/MM/yyyy') |
150 | }, | 154 | }, |
151 | { | 155 | { |
152 | label: 'Cotizacion:', | 156 | label: 'Cotizacion:', |
153 | valor: $filter('number')(notaPedido.cotizacion.VENDEDOR, | 157 | valor: $filter('number')(notaPedido.cotizacion.VENDEDOR, |
154 | '2') | 158 | '2') |
155 | }, | 159 | }, |
156 | { | 160 | { |
157 | label: 'Cliente:', | 161 | label: 'Cliente:', |
158 | valor: $filter('rellenarDigitos')(notaPedido.cliente.COD, 3) + | 162 | valor: $filter('rellenarDigitos')(notaPedido.cliente.COD, 3) + |
159 | ' - ' + notaPedido.cliente.NOM | 163 | ' - ' + notaPedido.cliente.NOM |
160 | }, | 164 | }, |
161 | { | 165 | { |
162 | label: 'Domicilio:', | 166 | label: 'Domicilio:', |
163 | valor: notaPedido.domicilioStamp | 167 | valor: notaPedido.domicilioStamp |
164 | }, | 168 | }, |
165 | { | 169 | { |
166 | label: 'Vendedor:', | 170 | label: 'Vendedor:', |
167 | valor: $filter('rellenarDigitos')( | 171 | valor: $filter('rellenarDigitos')( |
168 | notaPedido.vendedor.NUM, 3 | 172 | notaPedido.vendedor.NUM, 3 |
169 | ) + ' - ' + notaPedido.vendedor.NOM | 173 | ) + ' - ' + notaPedido.vendedor.NOM |
170 | }, | 174 | }, |
171 | { | 175 | { |
172 | label: 'Proveedor:', | 176 | label: 'Proveedor:', |
173 | valor: $filter('rellenarDigitos') | 177 | valor: $filter('rellenarDigitos') |
174 | (notaPedido.proveedor.COD, 5) + ' - ' + | 178 | (notaPedido.proveedor.COD, 5) + ' - ' + |
175 | notaPedido.proveedor.NOM | 179 | notaPedido.proveedor.NOM |
176 | }, | 180 | }, |
177 | { | 181 | { |
178 | label: 'Precio condicion:', | 182 | label: 'Precio condicion:', |
179 | valor: valorPrecioCondicion() + ' ' + | 183 | valor: valorPrecioCondicion() + ' ' + |
180 | remitoBusinessService | 184 | remitoBusinessService |
181 | .plazoToString(notaPedido.notaPedidoPlazo) | 185 | .plazoToString(notaPedido.notaPedidoPlazo) |
182 | }, | 186 | }, |
183 | { | 187 | { |
184 | label: 'Flete:', | 188 | label: 'Flete:', |
185 | valor: notaPedido.fob === 1 ? 'FOB' : ( | 189 | valor: notaPedido.fob === 1 ? 'FOB' : ( |
186 | notaPedido.flete === 1 ? 'Si' : 'No') | 190 | notaPedido.flete === 1 ? 'Si' : 'No') |
187 | }, | 191 | }, |
188 | { | 192 | { |
189 | label: 'Puntos de descarga: ', | 193 | label: 'Puntos de descarga: ', |
190 | valor: $filter('rellenarDigitos')( | 194 | valor: $filter('rellenarDigitos')( |
191 | getCabeceraPuntoDescarga(puntosDescarga)) | 195 | getCabeceraPuntoDescarga(puntosDescarga)) |
192 | } | 196 | } |
193 | ]; | 197 | ]; |
194 | 198 | ||
195 | function valorPrecioCondicion() { | 199 | function valorPrecioCondicion() { |
196 | if (notaPedido.idPrecioCondicion > 0) { | 200 | if (notaPedido.idPrecioCondicion > 0) { |
197 | return notaPedido.precioCondicion.nombre; | 201 | return notaPedido.precioCondicion.nombre; |
198 | } else { | 202 | } else { |
199 | return 'Ingreso Manual'; | 203 | return 'Ingreso Manual'; |
200 | } | 204 | } |
201 | } | 205 | } |
202 | 206 | ||
203 | if (notaPedido.flete === 1) { | 207 | if (notaPedido.flete === 1) { |
204 | var cabeceraBomba = { | 208 | var cabeceraBomba = { |
205 | label: 'Bomba:', | 209 | label: 'Bomba:', |
206 | valor: notaPedido.bomba === 1 ? 'Si' : 'No' | 210 | valor: notaPedido.bomba === 1 ? 'Si' : 'No' |
207 | }; | 211 | }; |
208 | if (notaPedido.kilometros) { | 212 | if (notaPedido.kilometros) { |
209 | var cabeceraKilometros = { | 213 | var cabeceraKilometros = { |
210 | label: 'Kilometros:', | 214 | label: 'Kilometros:', |
211 | valor: notaPedido.kilometros | 215 | valor: notaPedido.kilometros |
212 | }; | 216 | }; |
213 | cabeceras.push(cabeceraKilometros); | 217 | cabeceras.push(cabeceraKilometros); |
214 | } | 218 | } |
215 | cabeceras.push(cabeceraBomba); | 219 | cabeceras.push(cabeceraBomba); |
216 | } | 220 | } |
217 | 221 | ||
218 | delete notaPedido.id; | 222 | delete notaPedido.id; |
219 | $scope.remito = notaPedido; | 223 | $scope.remito = notaPedido; |
220 | $scope.remito.id = 0; | 224 | $scope.remito.id = 0; |
221 | $scope.remito.remitoPlazo = notaPedido.notaPedidoPlazo; | 225 | $scope.remito.remitoPlazo = notaPedido.notaPedidoPlazo; |
222 | 226 | ||
223 | for(var i = notaPedido.articulosNotaPedido.length - 1; i >= 0; i--) { | 227 | for(var i = notaPedido.articulosNotaPedido.length - 1; i >= 0; i--) { |
224 | notaPedido.articulosNotaPedido[i].id = 0; | 228 | notaPedido.articulosNotaPedido[i].id = 0; |
225 | notaPedido.articulosNotaPedido[i].idRemito = 0; | 229 | notaPedido.articulosNotaPedido[i].idRemito = 0; |
226 | } | 230 | } |
227 | 231 | ||
228 | $scope.remito.articulosRemito = notaPedido.articulosNotaPedido; | 232 | $scope.remito.articulosRemito = notaPedido.articulosNotaPedido; |
229 | 233 | ||
230 | if (notaPedido.idPrecioCondicion > 0) { | 234 | if (notaPedido.idPrecioCondicion > 0) { |
231 | $scope.idLista = notaPedido.precioCondicion.idListaPrecio; | 235 | $scope.idLista = notaPedido.precioCondicion.idListaPrecio; |
232 | } else { | 236 | } else { |
233 | $scope.idLista = -1; | 237 | $scope.idLista = -1; |
234 | } | 238 | } |
235 | 239 | ||
236 | enableObservaciones(notaPedido.observaciones ? true : false); | 240 | enableObservaciones(notaPedido.observaciones ? true : false); |
237 | addArrayCabecera(cabeceras); | 241 | addArrayCabecera(cabeceras); |
238 | 242 | ||
239 | }, function() { | 243 | }, function() { |
240 | // funcion ejecutada cuando se cancela el modal | 244 | // funcion ejecutada cuando se cancela el modal |
241 | } | 245 | } |
242 | ); | 246 | ); |
243 | } | 247 | } |
244 | }; | 248 | }; |
245 | 249 | ||
246 | $scope.seleccionarRemito = function() { | 250 | $scope.seleccionarRemito = function() { |
247 | var modalInstance = $uibModal.open( | 251 | var modalInstance = $uibModal.open( |
248 | { | 252 | { |
249 | ariaLabelledBy: 'Busqueda de Remito', | 253 | ariaLabelledBy: 'Busqueda de Remito', |
250 | templateUrl: 'foca-modal-remito.html', | 254 | templateUrl: 'foca-modal-remito.html', |
251 | controller: 'focaModalRemitoController', | 255 | controller: 'focaModalRemitoController', |
252 | size: 'lg', | 256 | size: 'lg', |
253 | resolve: {usadoPor: function() {return 'remito';}} | 257 | resolve: {usadoPor: function() {return 'remito';}} |
254 | } | 258 | } |
255 | ); | 259 | ); |
256 | modalInstance.result.then( | 260 | modalInstance.result.then( |
257 | setearRemito, function() { | 261 | setearRemito, function() { |
258 | // funcion ejecutada cuando se cancela el modal | 262 | // funcion ejecutada cuando se cancela el modal |
259 | } | 263 | } |
260 | ); | 264 | ); |
261 | }; | 265 | }; |
262 | 266 | ||
263 | //validacion por domicilio y por plazo pago | 267 | //validacion por domicilio y por plazo pago |
264 | $scope.crearRemito = function() { | 268 | $scope.crearRemito = function() { |
265 | if (!$scope.remito.vendedor.NUM) { | 269 | if (!$scope.remito.vendedor.NUM) { |
266 | focaModalService.alert('Ingrese Vendedor'); | 270 | focaModalService.alert('Ingrese Vendedor'); |
267 | return; | 271 | return; |
268 | } else if (!$scope.remito.cliente.COD) { | 272 | } else if (!$scope.remito.cliente.COD) { |
269 | focaModalService.alert('Ingrese Cliente'); | 273 | focaModalService.alert('Ingrese Cliente'); |
270 | return; | 274 | return; |
271 | } else if (!$scope.remito.proveedor) { | 275 | } else if (!$scope.remito.proveedor) { |
272 | focaModalService.alert('Ingrese Proveedor'); | 276 | focaModalService.alert('Ingrese Proveedor'); |
273 | return; | 277 | return; |
274 | } else if (!$scope.remito.cotizacion.moneda.id && | 278 | } else if (!$scope.remito.cotizacion.moneda.id && |
275 | !$scope.remito.cotizacion.moneda.ID){ | 279 | !$scope.remito.cotizacion.moneda.ID){ |
276 | focaModalService.alert('Ingrese Moneda'); | 280 | focaModalService.alert('Ingrese Moneda'); |
277 | return; | 281 | return; |
278 | } else if (!$scope.remito.cotizacion.ID) { | 282 | } else if (!$scope.remito.cotizacion.ID) { |
279 | focaModalService.alert('Ingrese Cotización'); | 283 | focaModalService.alert('Ingrese Cotización'); |
280 | return; | 284 | return; |
281 | } else if ($scope.remito.flete === undefined || $scope.remito.flete === null){ | 285 | } else if ($scope.remito.flete === undefined || $scope.remito.flete === null){ |
282 | focaModalService.alert('Ingrese Flete'); | 286 | focaModalService.alert('Ingrese Flete'); |
283 | return; | 287 | return; |
284 | } else if ($scope.articulosFiltro().length === 0) { | 288 | } else if ($scope.articulosFiltro().length === 0) { |
285 | focaModalService.alert('Debe cargar al menos un articulo'); | 289 | focaModalService.alert('Debe cargar al menos un articulo'); |
286 | return; | 290 | return; |
287 | } | 291 | } |
288 | focaBotoneraLateralService.startGuardar(); | 292 | focaBotoneraLateralService.startGuardar(); |
289 | $scope.saveLoading = true; | 293 | $scope.saveLoading = true; |
290 | var save = { | 294 | var save = { |
291 | remito: { | 295 | remito: { |
292 | id: $scope.remito.id, | 296 | id: $scope.remito.id, |
293 | fechaRemito: $scope.now.toISOString().slice(0, 19).replace('T', ' '), | 297 | fechaRemito: $scope.now.toISOString().slice(0, 19).replace('T', ' '), |
294 | idCliente: $scope.remito.cliente.COD, | 298 | idCliente: $scope.remito.cliente.COD, |
295 | nombreCliente: $scope.remito.cliente.NOM, | 299 | nombreCliente: $scope.remito.cliente.NOM, |
296 | cuitCliente: $scope.remito.cliente.CUIT, | 300 | cuitCliente: $scope.remito.cliente.CUIT, |
297 | total: $scope.getTotal() * $scope.remito.cotizacion.VENDEDOR, | 301 | total: $scope.getTotal() * $scope.remito.cotizacion.VENDEDOR, |
298 | numeroNotaPedido: $scope.remito.numeroNotaPedido, | 302 | numeroNotaPedido: $scope.remito.numeroNotaPedido, |
299 | idVendedor: $scope.remito.idVendedor, | 303 | idVendedor: $scope.remito.idVendedor, |
300 | idProveedor: $scope.remito.idProveedor, | 304 | idProveedor: $scope.remito.idProveedor, |
301 | idDomicilio: $scope.remito.idDomicilio, | 305 | idDomicilio: $scope.remito.idDomicilio, |
302 | idCotizacion: $scope.remito.cotizacion.ID, | 306 | idCotizacion: $scope.remito.cotizacion.ID, |
303 | idPrecioCondicion: $scope.remito.idPrecioCondicion, | 307 | idPrecioCondicion: $scope.remito.idPrecioCondicion, |
304 | flete: $scope.remito.flete, | 308 | flete: $scope.remito.flete, |
305 | fob: $scope.remito.fob, | 309 | fob: $scope.remito.fob, |
306 | bomba: $scope.remito.bomba, | 310 | bomba: $scope.remito.bomba, |
307 | kilometros: $scope.remito.kilometros, | 311 | kilometros: $scope.remito.kilometros, |
308 | domicilioStamp: $scope.remito.domicilioStamp, | 312 | domicilioStamp: $scope.remito.domicilioStamp, |
309 | observaciones: $scope.remito.observaciones, | 313 | observaciones: $scope.remito.observaciones, |
310 | numeroRemito: parseInt($scope.comprobante), | 314 | numeroRemito: parseInt($scope.comprobante), |
311 | sucursal: parseInt($scope.puntoVenta), | 315 | sucursal: parseInt($scope.puntoVenta), |
312 | responsabilidadIvaCliente: 0,//TODO CAMPO IVA CLIENTES | 316 | responsabilidadIvaCliente: $scope.remito.cliente.IVA, |
313 | descuento: 0,//TODO, | 317 | descuento: 0,//TODO, |
314 | importeNeto: 0,//TODO SUMATORIA NETO * CANTIDAD ARTICULOS | 318 | importeNeto: getImporte('netoUnitario'), |
315 | importeExento: 0,//TODO SUMATORIA EXENTO * CANTIDAD ARTICULOS | 319 | importeExento: getImporte('exentoUnitario'), |
316 | importeIva: 0,//TODO SUMATORIA IVA * CANTIDAD ARTICULOS | 320 | importeIva: getImporte('ivaUnitario'), |
317 | importeIvaServicios: 0,//TODO | 321 | importeIvaServicios: 0,//TODO |
318 | importeImpuestoInterno: 0,//SUMA importeImpuestoInterno * CANT ARTICULO | 322 | importeImpuestoInterno: getImporte('impuestoInternoUnitario'), |
319 | importeImpuestoInterno1: 0,//SUMA importeImpuestoInterno1 * CANT ARTICULO | 323 | importeImpuestoInterno1: getImporte('impuestoInterno1Unitario'), |
320 | importeImpuestoInterno2: 0,//SUMA importeImpuestoInterno2 * CANT ARTICULO | 324 | importeImpuestoInterno2: getImporte('impuestoInterno2Unitario'), |
321 | percepcion: 0,//TODO | 325 | percepcion: 0,//TODO |
322 | percepcionIva: 0,//TODO | 326 | percepcionIva: 0,//TODO |
323 | redondeo: 0,//TODO | 327 | redondeo: 0,//TODO |
324 | anulado: false, | 328 | anulado: false, |
325 | planilla: 0,//TODO DDMMYYYY | 329 | planilla: $filter('date')($scope.now, 'ddMMyyyy'), |
326 | lugar: 0,//SUCURSAL | 330 | lugar: parseInt($scope.puntoVenta), |
327 | cuentaMadre: 0,//TODO | 331 | cuentaMadre: 0,//TODO |
328 | cuentaContable: 0,//TODO | 332 | cuentaContable: 0,//TODO |
329 | asiento: 0,//TODO | 333 | asiento: 0,//TODO |
330 | e_hd: '',//TODO | 334 | e_hd: '',//TODO |
331 | c_hd: '', | 335 | c_hd: '', |
332 | numeroLiquidoProducto: 0,//TODO | 336 | numeroLiquidoProducto: 0,//TODO |
333 | estado: 0,//TODO | 337 | estado: 0, |
334 | destinoVenta: 0,//TODO | 338 | destinoVenta: 0,//TODO |
335 | operacionTipo: 0, //TODO | 339 | operacionTipo: 0, //TODO |
336 | }, | 340 | }, |
337 | notaPedido: $scope.notaPedido | 341 | notaPedido: $scope.notaPedido |
338 | }; | 342 | }; |
339 | 343 | ||
340 | crearRemitoService.crearRemito(save).then( | 344 | crearRemitoService.crearRemito(save).then( |
341 | function(data) { | 345 | function(data) { |
342 | 346 | ||
343 | focaBotoneraLateralService.endGuardar(true); | 347 | focaBotoneraLateralService.endGuardar(true); |
344 | $scope.saveLoading = false; | 348 | $scope.saveLoading = false; |
345 | 349 | ||
346 | $scope.remito.id = data.data.id; | 350 | $scope.remito.id = data.data.id; |
347 | $scope.remito.numeroRemito = data.data.numero; | 351 | $scope.remito.numeroRemito = data.data.numero; |
348 | 352 | ||
349 | remitoBusinessService.addArticulos($scope.remito.articulosRemito, | 353 | remitoBusinessService.addArticulos($scope.remito.articulosRemito, |
350 | $scope.remito.id, $scope.remito.cotizacion.VENDEDOR); | 354 | $scope.remito.id, $scope.remito.cotizacion.VENDEDOR); |
351 | 355 | ||
352 | if(data.status === 500) { | 356 | if(data.status === 500) { |
353 | focaModalService.alert(data.data); | 357 | focaModalService.alert(data.data); |
354 | return; | 358 | return; |
355 | } | 359 | } |
356 | 360 | ||
357 | // TODO: updatear plazos | 361 | // TODO: updatear plazos |
358 | if ($scope.remito.id === 0) { | 362 | if ($scope.remito.id === 0) { |
359 | var plazos = $scope.remito.remitoPlazo; | 363 | var plazos = $scope.remito.remitoPlazo; |
360 | 364 | ||
361 | for(var j = 0; j < plazos.length; j++) { | 365 | for(var j = 0; j < plazos.length; j++) { |
362 | var json = { | 366 | var json = { |
363 | idRemito: $scope.remito.id, | 367 | idRemito: $scope.remito.id, |
364 | dias: plazos[j].dias | 368 | dias: plazos[j].dias |
365 | }; | 369 | }; |
366 | crearRemitoService.crearPlazosParaRemito(json); | 370 | crearRemitoService.crearPlazosParaRemito(json); |
367 | } | 371 | } |
368 | } | 372 | } |
369 | 373 | ||
370 | abrirModalMail($scope.remito.id, | 374 | abrirModalMail($scope.remito.id, |
371 | $scope.remito.cliente, | 375 | $scope.remito.cliente, |
372 | $filter('comprobante')([ | 376 | $filter('comprobante')([ |
373 | $scope.puntoVenta, | 377 | $scope.puntoVenta, |
374 | $scope.remito.numeroRemito | 378 | $scope.remito.numeroRemito |
375 | ]) | 379 | ]) |
376 | ); | 380 | ); |
377 | 381 | ||
378 | init(); | 382 | init(); |
379 | 383 | ||
380 | }, function(error) { | 384 | }, function(error) { |
381 | focaModalService.alert(error.data || 'Hubo un error al crear el remito'); | 385 | focaModalService.alert(error.data || 'Hubo un error al crear el remito'); |
382 | focaBotoneraLateralService.endGuardar(); | 386 | focaBotoneraLateralService.endGuardar(); |
383 | $scope.saveLoading = false; | 387 | $scope.saveLoading = false; |
384 | console.info(error); | 388 | console.info(error); |
385 | } | 389 | } |
386 | ); | 390 | ); |
387 | }; | 391 | }; |
388 | 392 | ||
389 | $scope.seleccionarProductos = function() { | 393 | $scope.seleccionarProductos = function() { |
390 | if ($scope.idLista === undefined) { | 394 | if ($scope.idLista === undefined) { |
391 | focaModalService.alert( | 395 | focaModalService.alert( |
392 | 'Primero seleccione una lista de precio y condicion'); | 396 | 'Primero seleccione una lista de precio y condicion'); |
393 | return; | 397 | return; |
394 | } | 398 | } |
395 | var modalInstance = $uibModal.open( | 399 | var modalInstance = $uibModal.open( |
396 | { | 400 | { |
397 | ariaLabelledBy: 'Busqueda de Productos', | 401 | ariaLabelledBy: 'Busqueda de Productos', |
398 | templateUrl: 'modal-busqueda-productos.html', | 402 | templateUrl: 'modal-busqueda-productos.html', |
399 | controller: 'modalBusquedaProductosCtrl', | 403 | controller: 'modalBusquedaProductosCtrl', |
400 | resolve: { | 404 | resolve: { |
401 | parametroProducto: { | 405 | parametroProducto: { |
402 | idLista: $scope.idLista, | 406 | idLista: $scope.idLista, |
403 | cotizacion: $scope.remito.cotizacion.VENDEDOR, | 407 | cotizacion: $scope.remito.cotizacion.VENDEDOR, |
404 | simbolo: $scope.remito.cotizacion.moneda.SIMBOLO | 408 | simbolo: $scope.remito.cotizacion.moneda.SIMBOLO |
405 | } | 409 | } |
406 | }, | 410 | }, |
407 | size: 'lg' | 411 | size: 'lg' |
408 | } | 412 | } |
409 | ); | 413 | ); |
410 | modalInstance.result.then( | 414 | modalInstance.result.then( |
411 | function(producto) { | 415 | function(producto) { |
412 | var newArt = | 416 | var newArt = |
413 | { | 417 | { |
414 | id: 0, | 418 | id: 0, |
415 | idRemito: 0, | 419 | idRemito: 0, |
416 | codigo: producto.codigo, | 420 | codigo: producto.codigo, |
417 | sector: producto.sector, | 421 | sector: producto.sector, |
418 | sectorCodigo: producto.sector + '-' + producto.codigo, | 422 | sectorCodigo: producto.sector + '-' + producto.codigo, |
419 | descripcion: producto.descripcion, | 423 | descripcion: producto.descripcion, |
420 | item: $scope.remito.articulosRemito.length + 1, | 424 | item: $scope.remito.articulosRemito.length + 1, |
421 | nombre: producto.descripcion, | 425 | nombre: producto.descripcion, |
422 | precio: parseFloat(producto.precio.toFixed(4)), | 426 | precio: parseFloat(producto.precio.toFixed(4)), |
423 | costoUnitario: producto.costo, | 427 | costoUnitario: producto.costo, |
424 | editCantidad: false, | 428 | editCantidad: false, |
425 | editPrecio: false, | 429 | editPrecio: false, |
426 | rubro: producto.CodRub, | 430 | rubro: producto.CodRub, |
427 | exentoUnitario: producto.precio, | 431 | exentoUnitario: producto.precio, |
428 | ivaUnitario: producto.IMPIVA, | 432 | ivaUnitario: producto.IMPIVA, |
429 | impuestoInternoUnitario: producto.ImpInt, | 433 | impuestoInternoUnitario: producto.ImpInt, |
430 | impuestoInterno1Unitario: producto.ImpInt2, | 434 | impuestoInterno1Unitario: producto.ImpInt2, |
431 | impuestoInterno2Unitario: producto.ImpInt3, | 435 | impuestoInterno2Unitario: producto.ImpInt3, |
432 | precioLista: producto.precio, | 436 | precioLista: producto.precio, |
433 | combustible: 1, | 437 | combustible: 1, |
434 | facturado: 0 | 438 | facturado: 0 |
435 | }; | 439 | }; |
436 | $scope.articuloACargar = newArt; | 440 | $scope.articuloACargar = newArt; |
437 | $scope.cargando = false; | 441 | $scope.cargando = false; |
438 | }, function() { | 442 | }, function() { |
439 | // funcion ejecutada cuando se cancela el modal | 443 | // funcion ejecutada cuando se cancela el modal |
440 | } | 444 | } |
441 | ); | 445 | ); |
442 | }; | 446 | }; |
443 | 447 | ||
444 | $scope.seleccionarPuntosDeDescarga = function() { | 448 | $scope.seleccionarPuntosDeDescarga = function() { |
445 | if (!$scope.remito.cliente.COD || !$scope.remito.domicilio.id) { | 449 | if (!$scope.remito.cliente.COD || !$scope.remito.domicilio.id) { |
446 | focaModalService.alert('Primero seleccione un cliente y un domicilio'); | 450 | focaModalService.alert('Primero seleccione un cliente y un domicilio'); |
447 | return; | 451 | return; |
448 | } else { | 452 | } else { |
449 | var modalInstance = $uibModal.open( | 453 | var modalInstance = $uibModal.open( |
450 | { | 454 | { |
451 | ariaLabelledBy: 'Búsqueda de Puntos de descarga', | 455 | ariaLabelledBy: 'Búsqueda de Puntos de descarga', |
452 | templateUrl: 'modal-punto-descarga.html', | 456 | templateUrl: 'modal-punto-descarga.html', |
453 | controller: 'focaModalPuntoDescargaController', | 457 | controller: 'focaModalPuntoDescargaController', |
454 | size: 'lg', | 458 | size: 'lg', |
455 | resolve: { | 459 | resolve: { |
456 | filters: { | 460 | filters: { |
457 | idDomicilio: $scope.remito.domicilio.id, | 461 | idDomicilio: $scope.remito.domicilio.id, |
458 | idCliente: $scope.remito.cliente.COD, | 462 | idCliente: $scope.remito.cliente.COD, |
459 | articulos: $scope.remito.articulosRemito, | 463 | articulos: $scope.remito.articulosRemito, |
460 | puntosDescarga: $scope.remito.domicilio.puntosDescarga, | 464 | puntosDescarga: $scope.remito.domicilio.puntosDescarga, |
461 | domicilio: $scope.remito.domicilio | 465 | domicilio: $scope.remito.domicilio |
462 | } | 466 | } |
463 | } | 467 | } |
464 | } | 468 | } |
465 | ); | 469 | ); |
466 | modalInstance.result.then( | 470 | modalInstance.result.then( |
467 | function(puntosDescarga) { | 471 | function(puntosDescarga) { |
468 | $scope.remito.domicilio.puntosDescarga = puntosDescarga; | 472 | $scope.remito.domicilio.puntosDescarga = puntosDescarga; |
469 | 473 | ||
470 | $scope.$broadcast('addCabecera', { | 474 | $scope.$broadcast('addCabecera', { |
471 | label: 'Puntos de descarga:', | 475 | label: 'Puntos de descarga:', |
472 | valor: getCabeceraPuntoDescarga( | 476 | valor: getCabeceraPuntoDescarga( |
473 | $scope.remito.domicilio.puntosDescarga ) | 477 | $scope.remito.domicilio.puntosDescarga ) |
474 | }); | 478 | }); |
475 | }, function() { | 479 | }, function() { |
476 | $scope.abrirModalDomicilios($scope.cliente); | 480 | $scope.abrirModalDomicilios($scope.cliente); |
477 | } | 481 | } |
478 | ); | 482 | ); |
479 | } | 483 | } |
480 | }; | 484 | }; |
481 | 485 | ||
482 | $scope.seleccionarVendedor = function(callback, ocultarVendedor) { | 486 | $scope.seleccionarVendedor = function(callback, ocultarVendedor) { |
483 | if (ocultarVendedor) { | 487 | if (ocultarVendedor) { |
484 | callback(); | 488 | callback(); |
485 | return; | 489 | return; |
486 | } | 490 | } |
487 | 491 | ||
488 | if (varlidarRemitoFacturado()) { | 492 | if (varlidarRemitoFacturado()) { |
489 | var parametrosModal = { | 493 | var parametrosModal = { |
490 | titulo: 'Búsqueda vendedores', | 494 | titulo: 'Búsqueda vendedores', |
491 | query: '/vendedor', | 495 | query: '/vendedor', |
492 | columnas: [ | 496 | columnas: [ |
493 | { | 497 | { |
494 | propiedad: 'NUM', | 498 | propiedad: 'NUM', |
495 | nombre: 'Código', | 499 | nombre: 'Código', |
496 | filtro: { | 500 | filtro: { |
497 | nombre: 'rellenarDigitos', | 501 | nombre: 'rellenarDigitos', |
498 | parametro: 3 | 502 | parametro: 3 |
499 | } | 503 | } |
500 | }, | 504 | }, |
501 | { | 505 | { |
502 | propiedad: 'NOM', | 506 | propiedad: 'NOM', |
503 | nombre: 'Nombre' | 507 | nombre: 'Nombre' |
504 | } | 508 | } |
505 | ], | 509 | ], |
506 | size: 'md' | 510 | size: 'md' |
507 | }; | 511 | }; |
508 | focaModalService.modal(parametrosModal).then( | 512 | focaModalService.modal(parametrosModal).then( |
509 | function(vendedor) { | 513 | function(vendedor) { |
510 | $scope.$broadcast('addCabecera',{ | 514 | $scope.$broadcast('addCabecera',{ |
511 | label: 'Vendedor:', | 515 | label: 'Vendedor:', |
512 | valor: $filter('rellenarDigitos')(vendedor.NUM, 3) + ' - ' + | 516 | valor: $filter('rellenarDigitos')(vendedor.NUM, 3) + ' - ' + |
513 | vendedor.NOM | 517 | vendedor.NOM |
514 | }); | 518 | }); |
515 | $scope.remito.idVendedor = vendedor.id; | 519 | $scope.remito.idVendedor = vendedor.id; |
516 | $scope.remito.vendedor = vendedor; | 520 | $scope.remito.vendedor = vendedor; |
517 | deleteCliente(); | 521 | deleteCliente(); |
518 | callback(); | 522 | callback(); |
519 | }, function() { | 523 | }, function() { |
520 | 524 | ||
521 | } | 525 | } |
522 | ); | 526 | ); |
523 | } | 527 | } |
524 | }; | 528 | }; |
525 | 529 | ||
526 | $scope.seleccionarCliente = function(ocultarVendedor) { | 530 | $scope.seleccionarCliente = function(ocultarVendedor) { |
527 | 531 | ||
528 | $scope.seleccionarVendedor(function() { | 532 | $scope.seleccionarVendedor(function() { |
529 | if (varlidarRemitoFacturado()) { | 533 | if (varlidarRemitoFacturado()) { |
530 | var modalInstance = $uibModal.open( | 534 | var modalInstance = $uibModal.open( |
531 | { | 535 | { |
532 | ariaLabelledBy: 'Busqueda de Cliente', | 536 | ariaLabelledBy: 'Busqueda de Cliente', |
533 | templateUrl: 'foca-busqueda-cliente-modal.html', | 537 | templateUrl: 'foca-busqueda-cliente-modal.html', |
534 | controller: 'focaBusquedaClienteModalController', | 538 | controller: 'focaBusquedaClienteModalController', |
535 | resolve: { | 539 | resolve: { |
536 | vendedor: function() { return $scope.remito.vendedor; }, | 540 | vendedor: function() { return $scope.remito.vendedor; }, |
537 | cobrador: function() { return null; } | 541 | cobrador: function() { return null; } |
538 | }, | 542 | }, |
539 | size: 'lg' | 543 | size: 'lg' |
540 | } | 544 | } |
541 | ); | 545 | ); |
542 | modalInstance.result.then( | 546 | modalInstance.result.then( |
543 | function(cliente) { | 547 | function(cliente) { |
544 | $scope.abrirModalDomicilios(cliente); | 548 | $scope.abrirModalDomicilios(cliente); |
545 | $scope.cliente = cliente; | 549 | $scope.cliente = cliente; |
546 | }, function() { | 550 | }, function() { |
547 | $scope.seleccionarCliente(); | 551 | $scope.seleccionarCliente(); |
548 | } | 552 | } |
549 | ); | 553 | ); |
550 | } | 554 | } |
551 | }, ocultarVendedor); | 555 | }, ocultarVendedor); |
552 | }; | 556 | }; |
553 | 557 | ||
554 | $scope.seleccionarProveedor = function() { | 558 | $scope.seleccionarProveedor = function() { |
555 | if (varlidarRemitoFacturado()) { | 559 | if (varlidarRemitoFacturado()) { |
556 | var parametrosModal = { | 560 | var parametrosModal = { |
557 | titulo: 'Búsqueda de Proveedor', | 561 | titulo: 'Búsqueda de Proveedor', |
558 | query: '/proveedor', | 562 | query: '/proveedor', |
559 | columnas: [ | 563 | columnas: [ |
560 | { | 564 | { |
561 | nombre: 'Código', | 565 | nombre: 'Código', |
562 | propiedad: 'COD', | 566 | propiedad: 'COD', |
563 | filtro: { | 567 | filtro: { |
564 | nombre: 'rellenarDigitos', | 568 | nombre: 'rellenarDigitos', |
565 | parametro: 5 | 569 | parametro: 5 |
566 | } | 570 | } |
567 | }, | 571 | }, |
568 | { | 572 | { |
569 | nombre: 'Nombre', | 573 | nombre: 'Nombre', |
570 | propiedad: 'NOM' | 574 | propiedad: 'NOM' |
571 | }, | 575 | }, |
572 | { | 576 | { |
573 | nombre: 'CUIT', | 577 | nombre: 'CUIT', |
574 | propiedad: 'CUIT' | 578 | propiedad: 'CUIT' |
575 | } | 579 | } |
576 | ], | 580 | ], |
577 | tipo: 'POST', | 581 | tipo: 'POST', |
578 | json: {razonCuitCod: ''} | 582 | json: {razonCuitCod: ''} |
579 | }; | 583 | }; |
580 | focaModalService.modal(parametrosModal).then( | 584 | focaModalService.modal(parametrosModal).then( |
581 | function(proveedor) { | 585 | function(proveedor) { |
582 | $scope.seleccionarFlete(proveedor); | 586 | $scope.seleccionarFlete(proveedor); |
583 | }, function() { } | 587 | }, function() { } |
584 | ); | 588 | ); |
585 | } | 589 | } |
586 | }; | 590 | }; |
587 | 591 | ||
588 | $scope.abrirModalDomicilios = function(cliente) { | 592 | $scope.abrirModalDomicilios = function(cliente) { |
589 | var modalInstanceDomicilio = $uibModal.open( | 593 | var modalInstanceDomicilio = $uibModal.open( |
590 | { | 594 | { |
591 | ariaLabelledBy: 'Busqueda de Domicilios', | 595 | ariaLabelledBy: 'Busqueda de Domicilios', |
592 | templateUrl: 'modal-domicilio.html', | 596 | templateUrl: 'modal-domicilio.html', |
593 | controller: 'focaModalDomicilioController', | 597 | controller: 'focaModalDomicilioController', |
594 | size: 'lg', | 598 | size: 'lg', |
595 | resolve: { | 599 | resolve: { |
596 | idCliente: function() { return cliente.cod; }, | 600 | idCliente: function() { return cliente.cod; }, |
597 | esNuevo: function() { return cliente.esNuevo; } | 601 | esNuevo: function() { return cliente.esNuevo; } |
598 | } | 602 | } |
599 | } | 603 | } |
600 | ); | 604 | ); |
601 | modalInstanceDomicilio.result.then( | 605 | modalInstanceDomicilio.result.then( |
602 | function(domicilio) { | 606 | function(domicilio) { |
603 | $scope.remito.domicilio = domicilio; | 607 | $scope.remito.domicilio = domicilio; |
604 | console.log(cliente); | 608 | console.log(cliente); |
605 | $scope.remito.cliente = { | 609 | $scope.remito.cliente = { |
606 | COD: cliente.cod, | 610 | COD: cliente.cod, |
607 | CUIT: cliente.cuit, | 611 | CUIT: cliente.cuit, |
608 | NOM: cliente.nom, | 612 | NOM: cliente.nom, |
609 | MAIL: cliente.mail, | 613 | MAIL: cliente.mail, |
610 | MOD: cliente.mod | 614 | MOD: cliente.mod, |
615 | IVA: cliente.iva | ||
611 | }; | 616 | }; |
612 | 617 | ||
613 | var domicilioStamp = | 618 | var domicilioStamp = |
614 | domicilio.Calle + ' ' + domicilio.Numero + ', ' + | 619 | domicilio.Calle + ' ' + domicilio.Numero + ', ' + |
615 | domicilio.Localidad + ', ' + domicilio.Provincia; | 620 | domicilio.Localidad + ', ' + domicilio.Provincia; |
616 | $scope.remito.domicilioStamp = domicilioStamp; | 621 | $scope.remito.domicilioStamp = domicilioStamp; |
617 | $scope.$broadcast('addCabecera',{ | 622 | $scope.$broadcast('addCabecera',{ |
618 | label: 'Cliente:', | 623 | label: 'Cliente:', |
619 | valor: $filter('rellenarDigitos')(cliente.cod, 3) + ' - ' + cliente.nom | 624 | valor: $filter('rellenarDigitos')(cliente.cod, 3) + ' - ' + cliente.nom |
620 | }); | 625 | }); |
621 | $scope.$broadcast('addCabecera',{ | 626 | $scope.$broadcast('addCabecera',{ |
622 | label: 'Domicilio:', | 627 | label: 'Domicilio:', |
623 | valor: domicilioStamp | 628 | valor: domicilioStamp |
624 | }); | 629 | }); |
625 | 630 | ||
626 | if (domicilio.verPuntos) { | 631 | if (domicilio.verPuntos) { |
627 | delete $scope.remito.domicilio.verPuntos; | 632 | delete $scope.remito.domicilio.verPuntos; |
628 | $scope.seleccionarPuntosDeDescarga(); | 633 | $scope.seleccionarPuntosDeDescarga(); |
629 | } else { | 634 | } else { |
630 | crearRemitoService | 635 | crearRemitoService |
631 | .getPuntosDescargaByClienDom(domicilio.id, cliente.cod) | 636 | .getPuntosDescargaByClienDom(domicilio.id, cliente.cod) |
632 | .then(function(res) { | 637 | .then(function(res) { |
633 | if (res.data.length) $scope.seleccionarPuntosDeDescarga(); | 638 | if (res.data.length) $scope.seleccionarPuntosDeDescarga(); |
634 | }); | 639 | }); |
635 | } | 640 | } |
636 | }, function() { | 641 | }, function() { |
637 | $scope.seleccionarCliente(true); | 642 | $scope.seleccionarCliente(true); |
638 | return; | 643 | return; |
639 | } | 644 | } |
640 | ); | 645 | ); |
641 | }; | 646 | }; |
642 | 647 | ||
643 | $scope.getTotal = function() { | 648 | $scope.getTotal = function() { |
644 | var total = 0; | 649 | var total = 0; |
645 | var arrayTempArticulos = $scope.articulosFiltro(); | 650 | var arrayTempArticulos = $scope.articulosFiltro(); |
646 | for(var i = 0; i < arrayTempArticulos.length; i++) { | 651 | for(var i = 0; i < arrayTempArticulos.length; i++) { |
647 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; | 652 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; |
648 | } | 653 | } |
649 | return parseFloat(total.toFixed(2)); | 654 | return parseFloat(total.toFixed(2)); |
650 | }; | 655 | }; |
651 | 656 | ||
652 | $scope.getSubTotal = function() { | 657 | $scope.getSubTotal = function() { |
653 | if ($scope.articuloACargar) { | 658 | if ($scope.articuloACargar) { |
654 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; | 659 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; |
655 | } | 660 | } |
656 | }; | 661 | }; |
657 | 662 | ||
658 | $scope.seleccionarPreciosYCondiciones = function() { | 663 | $scope.seleccionarPreciosYCondiciones = function() { |
659 | if (!$scope.remito.cliente.COD) { | 664 | if (!$scope.remito.cliente.COD) { |
660 | focaModalService.alert('Primero seleccione un cliente'); | 665 | focaModalService.alert('Primero seleccione un cliente'); |
661 | return; | 666 | return; |
662 | } | 667 | } |
663 | 668 | ||
664 | if ($scope.remito.articulosRemito.length !== 0) { | 669 | if ($scope.remito.articulosRemito.length !== 0) { |
665 | focaModalService.confirm('Se perderan los productos ingresados') | 670 | focaModalService.confirm('Se perderan los productos ingresados') |
666 | .then(function(data) { | 671 | .then(function(data) { |
667 | if (data && varlidarRemitoFacturado()) { | 672 | if (data && varlidarRemitoFacturado()) { |
668 | abrirModal(); | 673 | abrirModal(); |
669 | } | 674 | } |
670 | }); | 675 | }); |
671 | } else { | 676 | } else { |
672 | abrirModal(); | 677 | abrirModal(); |
673 | } | 678 | } |
674 | 679 | ||
675 | function abrirModal() { | 680 | function abrirModal() { |
676 | var modalInstance = $uibModal.open( | 681 | var modalInstance = $uibModal.open( |
677 | { | 682 | { |
678 | ariaLabelledBy: 'Busqueda de Precio Condición', | 683 | ariaLabelledBy: 'Busqueda de Precio Condición', |
679 | templateUrl: 'modal-precio-condicion.html', | 684 | templateUrl: 'modal-precio-condicion.html', |
680 | controller: 'focaModalPrecioCondicionController', | 685 | controller: 'focaModalPrecioCondicionController', |
681 | size: 'lg', | 686 | size: 'lg', |
682 | resolve: { | 687 | resolve: { |
683 | idListaPrecio: function() { | 688 | idListaPrecio: function() { |
684 | return $scope.remito.cliente.MOD || null; | 689 | return $scope.remito.cliente.MOD || null; |
685 | } | 690 | } |
686 | } | 691 | } |
687 | } | 692 | } |
688 | ); | 693 | ); |
689 | modalInstance.result.then( | 694 | modalInstance.result.then( |
690 | function(precioCondicion) { | 695 | function(precioCondicion) { |
691 | var cabecera = ''; | 696 | var cabecera = ''; |
692 | var plazosConcat = ''; | 697 | var plazosConcat = ''; |
693 | if (!Array.isArray(precioCondicion)) { | 698 | if (!Array.isArray(precioCondicion)) { |
694 | $scope.remito.idPrecioCondicion = precioCondicion.id; | 699 | $scope.remito.idPrecioCondicion = precioCondicion.id; |
695 | $scope.remito.remitoPlazo = precioCondicion.plazoPago; | 700 | $scope.remito.remitoPlazo = precioCondicion.plazoPago; |
696 | $scope.idLista = precioCondicion.idListaPrecio; | 701 | $scope.idLista = precioCondicion.idListaPrecio; |
697 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { | 702 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { |
698 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; | 703 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; |
699 | } | 704 | } |
700 | cabecera = $filter('rellenarDigitos')(precioCondicion.id, 4) + | 705 | cabecera = $filter('rellenarDigitos')(precioCondicion.id, 4) + |
701 | ' - ' + precioCondicion.nombre + ' ' + plazosConcat.trim(); | 706 | ' - ' + precioCondicion.nombre + ' ' + plazosConcat.trim(); |
702 | } else { //Cuando se ingresan los plazos manualmente | 707 | } else { //Cuando se ingresan los plazos manualmente |
703 | $scope.remito.idPrecioCondicion = 0; | 708 | $scope.remito.idPrecioCondicion = 0; |
704 | //-1, el modal productos busca todos los productos | 709 | //-1, el modal productos busca todos los productos |
705 | $scope.idLista = -1; | 710 | $scope.idLista = -1; |
706 | $scope.remito.remitoPlazo = precioCondicion; | 711 | $scope.remito.remitoPlazo = precioCondicion; |
707 | for(var j = 0; j < precioCondicion.length; j++) { | 712 | for(var j = 0; j < precioCondicion.length; j++) { |
708 | plazosConcat += precioCondicion[j].dias + ' '; | 713 | plazosConcat += precioCondicion[j].dias + ' '; |
709 | } | 714 | } |
710 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); | 715 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); |
711 | } | 716 | } |
712 | $scope.remito.articulosRemito = []; | 717 | $scope.remito.articulosRemito = []; |
713 | $scope.$broadcast('addCabecera',{ | 718 | $scope.$broadcast('addCabecera',{ |
714 | label: 'Precios y condiciones:', | 719 | label: 'Precios y condiciones:', |
715 | valor: cabecera | 720 | valor: cabecera |
716 | }); | 721 | }); |
717 | $scope.remito.precioCondicion = precioCondicion; | 722 | $scope.remito.precioCondicion = precioCondicion; |
718 | }, function() { | 723 | }, function() { |
719 | 724 | ||
720 | } | 725 | } |
721 | ); | 726 | ); |
722 | } | 727 | } |
723 | }; | 728 | }; |
724 | 729 | ||
725 | $scope.seleccionarFlete = function(proveedor) { | 730 | $scope.seleccionarFlete = function(proveedor) { |
726 | if (varlidarRemitoFacturado()) { | 731 | if (varlidarRemitoFacturado()) { |
727 | var modalInstance = $uibModal.open( | 732 | var modalInstance = $uibModal.open( |
728 | { | 733 | { |
729 | ariaLabelledBy: 'Busqueda de Flete', | 734 | ariaLabelledBy: 'Busqueda de Flete', |
730 | templateUrl: 'modal-flete.html', | 735 | templateUrl: 'modal-flete.html', |
731 | controller: 'focaModalFleteController', | 736 | controller: 'focaModalFleteController', |
732 | size: 'lg', | 737 | size: 'lg', |
733 | resolve: { | 738 | resolve: { |
734 | parametrosFlete: | 739 | parametrosFlete: |
735 | function() { | 740 | function() { |
736 | return { | 741 | return { |
737 | flete: $scope.remito.flete ? '1' : | 742 | flete: $scope.remito.flete ? '1' : |
738 | ($scope.remito.fob ? 'FOB' : | 743 | ($scope.remito.fob ? 'FOB' : |
739 | ($scope.remito.flete === undefined ? | 744 | ($scope.remito.flete === undefined ? |
740 | null : '0')), | 745 | null : '0')), |
741 | bomba: $scope.remito.bomba ? '1' : | 746 | bomba: $scope.remito.bomba ? '1' : |
742 | ($scope.remito.bomba === undefined ? | 747 | ($scope.remito.bomba === undefined ? |
743 | null : '0'), | 748 | null : '0'), |
744 | kilometros: $scope.remito.kilometros | 749 | kilometros: $scope.remito.kilometros |
745 | }; | 750 | }; |
746 | } | 751 | } |
747 | } | 752 | } |
748 | } | 753 | } |
749 | ); | 754 | ); |
750 | modalInstance.result.then( | 755 | modalInstance.result.then( |
751 | function(datos) { | 756 | function(datos) { |
752 | 757 | ||
753 | $scope.remito.proveedor = proveedor; | 758 | $scope.remito.proveedor = proveedor; |
754 | $scope.remito.idProveedor = proveedor.COD; | 759 | $scope.remito.idProveedor = proveedor.COD; |
755 | $scope.$broadcast('addCabecera',{ | 760 | $scope.$broadcast('addCabecera',{ |
756 | label: 'Proveedor:', | 761 | label: 'Proveedor:', |
757 | valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + | 762 | valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + |
758 | proveedor.NOM | 763 | proveedor.NOM |
759 | }); | 764 | }); |
760 | 765 | ||
761 | $scope.remito.flete = datos.flete; | 766 | $scope.remito.flete = datos.flete; |
762 | $scope.remito.fob = datos.FOB; | 767 | $scope.remito.fob = datos.FOB; |
763 | $scope.remito.bomba = datos.bomba; | 768 | $scope.remito.bomba = datos.bomba; |
764 | $scope.remito.kilometros = datos.kilometros; | 769 | $scope.remito.kilometros = datos.kilometros; |
765 | 770 | ||
766 | $scope.$broadcast('addCabecera',{ | 771 | $scope.$broadcast('addCabecera',{ |
767 | label: 'Flete:', | 772 | label: 'Flete:', |
768 | valor: datos.flete ? 'Si' : ($scope.remito.fob ? 'FOB' : 'No') | 773 | valor: datos.flete ? 'Si' : ($scope.remito.fob ? 'FOB' : 'No') |
769 | }); | 774 | }); |
770 | if (datos.flete) { | 775 | if (datos.flete) { |
771 | $scope.$broadcast('addCabecera',{ | 776 | $scope.$broadcast('addCabecera',{ |
772 | label: 'Bomba:', | 777 | label: 'Bomba:', |
773 | valor: datos.bomba ? 'Si' : 'No' | 778 | valor: datos.bomba ? 'Si' : 'No' |
774 | }); | 779 | }); |
775 | $scope.$broadcast('addCabecera',{ | 780 | $scope.$broadcast('addCabecera',{ |
776 | label: 'Kilometros:', | 781 | label: 'Kilometros:', |
777 | valor: datos.kilometros | 782 | valor: datos.kilometros |
778 | }); | 783 | }); |
779 | } else { | 784 | } else { |
780 | $scope.$broadcast('removeCabecera', 'Bomba:'); | 785 | $scope.$broadcast('removeCabecera', 'Bomba:'); |
781 | $scope.$broadcast('removeCabecera', 'Kilometros:'); | 786 | $scope.$broadcast('removeCabecera', 'Kilometros:'); |
782 | $scope.remito.bomba = false; | 787 | $scope.remito.bomba = false; |
783 | $scope.remito.kilometros = null; | 788 | $scope.remito.kilometros = null; |
784 | } | 789 | } |
785 | }, function() { | 790 | }, function() { |
786 | $scope.seleccionarTransportista(); | 791 | $scope.seleccionarTransportista(); |
787 | } | 792 | } |
788 | ); | 793 | ); |
789 | } | 794 | } |
790 | }; | 795 | }; |
791 | 796 | ||
792 | $scope.seleccionarMoneda = function() { | 797 | $scope.seleccionarMoneda = function() { |
793 | if (varlidarRemitoFacturado()) { | 798 | if (varlidarRemitoFacturado()) { |
794 | var parametrosModal = { | 799 | var parametrosModal = { |
795 | titulo: 'Búsqueda de monedas', | 800 | titulo: 'Búsqueda de monedas', |
796 | query: '/moneda', | 801 | query: '/moneda', |
797 | columnas: [ | 802 | columnas: [ |
798 | { | 803 | { |
799 | propiedad: 'DETALLE', | 804 | propiedad: 'DETALLE', |
800 | nombre: 'Nombre' | 805 | nombre: 'Nombre' |
801 | }, | 806 | }, |
802 | { | 807 | { |
803 | propiedad: 'SIMBOLO', | 808 | propiedad: 'SIMBOLO', |
804 | nombre: 'Símbolo' | 809 | nombre: 'Símbolo' |
805 | } | 810 | } |
806 | ], | 811 | ], |
807 | size: 'md' | 812 | size: 'md' |
808 | }; | 813 | }; |
809 | focaModalService.modal(parametrosModal).then( | 814 | focaModalService.modal(parametrosModal).then( |
810 | function(moneda) { | 815 | function(moneda) { |
811 | $scope.abrirModalCotizacion(moneda); | 816 | $scope.abrirModalCotizacion(moneda); |
812 | }, function() { | 817 | }, function() { |
813 | 818 | ||
814 | } | 819 | } |
815 | ); | 820 | ); |
816 | } | 821 | } |
817 | }; | 822 | }; |
818 | 823 | ||
819 | $scope.seleccionarObservaciones = function() { | 824 | $scope.seleccionarObservaciones = function() { |
820 | focaModalService | 825 | focaModalService |
821 | .prompt({ | 826 | .prompt({ |
822 | titulo: 'Observaciones', | 827 | titulo: 'Observaciones', |
823 | value: $scope.remito.observaciones, | 828 | value: $scope.remito.observaciones, |
824 | textarea: true, | 829 | textarea: true, |
825 | readonly: true | 830 | readonly: true |
826 | }) | 831 | }) |
827 | .then(function(observaciones) { | 832 | .then(function(observaciones) { |
828 | $scope.remito.observaciones = observaciones; | 833 | $scope.remito.observaciones = observaciones; |
829 | }); | 834 | }); |
830 | }; | 835 | }; |
831 | 836 | ||
832 | $scope.abrirModalCotizacion = function(moneda) { | 837 | $scope.abrirModalCotizacion = function(moneda) { |
833 | var modalInstance = $uibModal.open( | 838 | var modalInstance = $uibModal.open( |
834 | { | 839 | { |
835 | ariaLabelledBy: 'Busqueda de Cotización', | 840 | ariaLabelledBy: 'Busqueda de Cotización', |
836 | templateUrl: 'modal-cotizacion.html', | 841 | templateUrl: 'modal-cotizacion.html', |
837 | controller: 'focaModalCotizacionController', | 842 | controller: 'focaModalCotizacionController', |
838 | size: 'lg', | 843 | size: 'lg', |
839 | resolve: {idMoneda: function() {return moneda.ID;}} | 844 | resolve: {idMoneda: function() {return moneda.ID;}} |
840 | } | 845 | } |
841 | ); | 846 | ); |
842 | modalInstance.result.then( | 847 | modalInstance.result.then( |
843 | function(cotizacion) { | 848 | function(cotizacion) { |
844 | var articulosTablaTemp = $scope.remito.articulosRemito; | 849 | var articulosTablaTemp = $scope.remito.articulosRemito; |
845 | for(var i = 0; i < articulosTablaTemp.length; i++) { | 850 | for(var i = 0; i < articulosTablaTemp.length; i++) { |
846 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * | 851 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * |
847 | $scope.remito.cotizacion.VENDEDOR; | 852 | $scope.remito.cotizacion.VENDEDOR; |
848 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / | 853 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / |
849 | cotizacion.VENDEDOR; | 854 | cotizacion.VENDEDOR; |
850 | } | 855 | } |
851 | $scope.remito.articulosRemito = articulosTablaTemp; | 856 | $scope.remito.articulosRemito = articulosTablaTemp; |
852 | $scope.remito.cotizacion = cotizacion; | 857 | $scope.remito.cotizacion = cotizacion; |
853 | $scope.remito.cotizacion.moneda = moneda; | 858 | $scope.remito.cotizacion.moneda = moneda; |
854 | if (moneda.DETALLE === 'PESOS ARGENTINOS') { | 859 | if (moneda.DETALLE === 'PESOS ARGENTINOS') { |
855 | $scope.$broadcast('removeCabecera', 'Moneda:'); | 860 | $scope.$broadcast('removeCabecera', 'Moneda:'); |
856 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); | 861 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); |
857 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); | 862 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); |
858 | } else { | 863 | } else { |
859 | $scope.$broadcast('addCabecera',{ | 864 | $scope.$broadcast('addCabecera',{ |
860 | label: 'Moneda:', | 865 | label: 'Moneda:', |
861 | valor: moneda.DETALLE | 866 | valor: moneda.DETALLE |
862 | }); | 867 | }); |
863 | $scope.$broadcast('addCabecera',{ | 868 | $scope.$broadcast('addCabecera',{ |
864 | label: 'Fecha cotizacion:', | 869 | label: 'Fecha cotizacion:', |
865 | valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') | 870 | valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') |
866 | }); | 871 | }); |
867 | $scope.$broadcast('addCabecera',{ | 872 | $scope.$broadcast('addCabecera',{ |
868 | label: 'Cotizacion:', | 873 | label: 'Cotizacion:', |
869 | valor: $filter('number')(cotizacion.VENDEDOR, '2') | 874 | valor: $filter('number')(cotizacion.VENDEDOR, '2') |
870 | }); | 875 | }); |
871 | } | 876 | } |
872 | }, function() { | 877 | }, function() { |
873 | 878 | ||
874 | } | 879 | } |
875 | ); | 880 | ); |
876 | }; | 881 | }; |
877 | 882 | ||
878 | $scope.agregarATabla = function(key) { | 883 | $scope.agregarATabla = function(key) { |
879 | if (key === 13) { | 884 | if (key === 13) { |
880 | if ($scope.articuloACargar.cantidad === undefined || | 885 | if ($scope.articuloACargar.cantidad === undefined || |
881 | $scope.articuloACargar.cantidad === 0 || | 886 | $scope.articuloACargar.cantidad === 0 || |
882 | $scope.articuloACargar.cantidad === null ) { | 887 | $scope.articuloACargar.cantidad === null ) { |
883 | focaModalService.alert('El valor debe ser al menos 1'); | 888 | focaModalService.alert('El valor debe ser al menos 1'); |
884 | return; | 889 | return; |
885 | } | 890 | } |
886 | delete $scope.articuloACargar.sectorCodigo; | 891 | delete $scope.articuloACargar.sectorCodigo; |
887 | $scope.remito.articulosRemito.push($scope.articuloACargar); | 892 | $scope.remito.articulosRemito.push($scope.articuloACargar); |
888 | $scope.cargando = true; | 893 | $scope.cargando = true; |
889 | } | 894 | } |
890 | }; | 895 | }; |
891 | 896 | ||
892 | $scope.quitarArticulo = function(articulo) { | 897 | $scope.quitarArticulo = function(articulo) { |
893 | articulo.idRemito = -1; | 898 | articulo.idRemito = -1; |
894 | }; | 899 | }; |
895 | 900 | ||
896 | $scope.articulosFiltro = function() { | 901 | $scope.articulosFiltro = function() { |
897 | 902 | ||
898 | var result = $scope.remito.articulosRemito.filter(function(articulo) { | 903 | var result = $scope.remito.articulosRemito.filter(function(articulo) { |
899 | return articulo.idRemito >= 0; | 904 | return articulo.idRemito >= 0; |
900 | }); | 905 | }); |
901 | return result; | 906 | return result; |
902 | }; | 907 | }; |
903 | 908 | ||
904 | $scope.editarArticulo = function(key, articulo, tmpCantidad, tmpPrecio) { | 909 | $scope.editarArticulo = function(key, articulo, tmpCantidad, tmpPrecio) { |
905 | if (key === 13) { | 910 | if (key === 13) { |
906 | if (!articulo.cantidad || !articulo.precio) { | 911 | if (!articulo.cantidad || !articulo.precio) { |
907 | focaModalService.alert('Los valores deben ser al menos 1'); | 912 | focaModalService.alert('Los valores deben ser al menos 1'); |
908 | return; | 913 | return; |
909 | } else if (articulo.cantidad < 0 || articulo.precio < 0) { | 914 | } else if (articulo.cantidad < 0 || articulo.precio < 0) { |
910 | focaModalService.alert('Los valores no pueden ser negativos'); | 915 | focaModalService.alert('Los valores no pueden ser negativos'); |
911 | return; | 916 | return; |
912 | } | 917 | } |
913 | articulo.cantidad = tmpCantidad; | 918 | articulo.cantidad = tmpCantidad; |
914 | articulo.precio = tmpPrecio; | 919 | articulo.precio = tmpPrecio; |
915 | $scope.getTotal(); | 920 | $scope.getTotal(); |
916 | articulo.editCantidad = articulo.editPrecio = false; | 921 | articulo.editCantidad = articulo.editPrecio = false; |
917 | } | 922 | } |
918 | }; | 923 | }; |
919 | 924 | ||
920 | $scope.cancelarEditar = function(articulo) { | 925 | $scope.cancelarEditar = function(articulo) { |
921 | $scope.tmpCantidad = articulo.cantidad; | 926 | $scope.tmpCantidad = articulo.cantidad; |
922 | $scope.tmpPrecio = articulo.precio; | 927 | $scope.tmpPrecio = articulo.precio; |
923 | articulo.editCantidad = articulo.editPrecio = false; | 928 | articulo.editCantidad = articulo.editPrecio = false; |
924 | }; | 929 | }; |
925 | 930 | ||
926 | $scope.cambioEdit = function(articulo, propiedad) { | 931 | $scope.cambioEdit = function(articulo, propiedad) { |
927 | if (propiedad === 'cantidad') { | 932 | if (propiedad === 'cantidad') { |
928 | articulo.editCantidad = true; | 933 | articulo.editCantidad = true; |
929 | } else if (propiedad === 'precio') { | 934 | } else if (propiedad === 'precio') { |
930 | articulo.editPrecio = true; | 935 | articulo.editPrecio = true; |
931 | } | 936 | } |
932 | }; | 937 | }; |
933 | 938 | ||
934 | $scope.resetFilter = function() { | 939 | $scope.resetFilter = function() { |
935 | $scope.articuloACargar = {}; | 940 | $scope.articuloACargar = {}; |
936 | $scope.cargando = true; | 941 | $scope.cargando = true; |
937 | }; | 942 | }; |
938 | //Recibe aviso si el teclado está en uso | 943 | //Recibe aviso si el teclado está en uso |
939 | $rootScope.$on('usarTeclado', function(event, data) { | 944 | $rootScope.$on('usarTeclado', function(event, data) { |
940 | if (data) { | 945 | if (data) { |
941 | $scope.mostrarTeclado = true; | 946 | $scope.mostrarTeclado = true; |
942 | return; | 947 | return; |
943 | } | 948 | } |
944 | $scope.mostrarTeclado = false; | 949 | $scope.mostrarTeclado = false; |
945 | }); | 950 | }); |
946 | 951 | ||
947 | $scope.selectFocus = function($event) { | 952 | $scope.selectFocus = function($event) { |
948 | // Si el teclado esta en uso no selecciona el valor | 953 | // Si el teclado esta en uso no selecciona el valor |
949 | if ($scope.mostrarTeclado) { | 954 | if ($scope.mostrarTeclado) { |
950 | return; | 955 | return; |
951 | } | 956 | } |
952 | $event.target.select(); | 957 | $event.target.select(); |
953 | }; | 958 | }; |
954 | 959 | ||
955 | function addArrayCabecera(array) { | 960 | function addArrayCabecera(array) { |
956 | for (var i = 0; i < array.length; i++) { | 961 | for (var i = 0; i < array.length; i++) { |
957 | $scope.$broadcast('addCabecera',{ | 962 | $scope.$broadcast('addCabecera',{ |
958 | label: array[i].label, | 963 | label: array[i].label, |
959 | valor: array[i].valor | 964 | valor: array[i].valor |
960 | }); | 965 | }); |
961 | } | 966 | } |
962 | } | 967 | } |
963 | 968 | ||
964 | function rellenar(relleno, longitud) { | 969 | function rellenar(relleno, longitud) { |
965 | relleno = '' + relleno; | 970 | relleno = '' + relleno; |
966 | while (relleno.length < longitud) { | 971 | while (relleno.length < longitud) { |
967 | relleno = '0' + relleno; | 972 | relleno = '0' + relleno; |
968 | } | 973 | } |
969 | return relleno; | 974 | return relleno; |
970 | } | 975 | } |
971 | 976 | ||
972 | function varlidarRemitoFacturado() { | 977 | function varlidarRemitoFacturado() { |
973 | if ($scope.remito.estado !== 5) { | 978 | if ($scope.remito.estado !== 5) { |
974 | return true; | 979 | return true; |
975 | } else { | 980 | } else { |
976 | focaModalService.alert('No se puede editar un remito facturado'); | 981 | focaModalService.alert('No se puede editar un remito facturado'); |
977 | return false(); | 982 | return false(); |
978 | } | 983 | } |
979 | } | 984 | } |
980 | 985 | ||
981 | function salir() { | 986 | function salir() { |
982 | var confirmacion = false; | 987 | var confirmacion = false; |
983 | 988 | ||
984 | if (!angular.equals($scope.remito, $scope.inicial)) { | 989 | if (!angular.equals($scope.remito, $scope.inicial)) { |
985 | confirmacion = true; | 990 | confirmacion = true; |
986 | } | 991 | } |
987 | 992 | ||
988 | if (confirmacion) { | 993 | if (confirmacion) { |
989 | focaModalService.confirm( | 994 | focaModalService.confirm( |
990 | '¿Está seguro de que desea salir? Se perderán todos los datos cargados.' | 995 | '¿Está seguro de que desea salir? Se perderán todos los datos cargados.' |
991 | ).then(function(data) { | 996 | ).then(function(data) { |
992 | if (data) { | 997 | if (data) { |
993 | $location.path('/'); | 998 | $location.path('/'); |
994 | } | 999 | } |
995 | }); | 1000 | }); |
996 | } else { | 1001 | } else { |
997 | $location.path('/'); | 1002 | $location.path('/'); |
998 | } | 1003 | } |
999 | } | 1004 | } |
1000 | 1005 | ||
1001 | function enableObservaciones(val) { | 1006 | function enableObservaciones(val) { |
1002 | var boton = $scope.botonera.filter(function(botonObs) { | 1007 | var boton = $scope.botonera.filter(function(botonObs) { |
1003 | return botonObs.label === 'Observaciones'; | 1008 | return botonObs.label === 'Observaciones'; |
1004 | }); | 1009 | }); |
1005 | boton[0].disable = !val; | 1010 | boton[0].disable = !val; |
1006 | } | 1011 | } |
1007 | 1012 | ||
1008 | function setearRemito(remito) { | 1013 | function setearRemito(remito) { |
1009 | //añado cabeceras | 1014 | //añado cabeceras |
1010 | $scope.$broadcast('removeCabecera', 'Moneda:'); | 1015 | $scope.$broadcast('removeCabecera', 'Moneda:'); |
1011 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); | 1016 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); |
1012 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); | 1017 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); |
1013 | 1018 | ||
1014 | var cabeceras = []; | 1019 | var cabeceras = []; |
1015 | 1020 | ||
1016 | if (remito.cotizacion.moneda.CODIGO_AFIP !== 'PES') { | 1021 | if (remito.cotizacion.moneda.CODIGO_AFIP !== 'PES') { |
1017 | cabeceras.push({ | 1022 | cabeceras.push({ |
1018 | label: 'Moneda:', | 1023 | label: 'Moneda:', |
1019 | valor: remito.cotizacion.moneda.DETALLE | 1024 | valor: remito.cotizacion.moneda.DETALLE |
1020 | }); | 1025 | }); |
1021 | cabeceras.push({ | 1026 | cabeceras.push({ |
1022 | label: 'Fecha cotizacion:', | 1027 | label: 'Fecha cotizacion:', |
1023 | valor: $filter('date')(remito.cotizacion.FECHA, | 1028 | valor: $filter('date')(remito.cotizacion.FECHA, |
1024 | 'dd/MM/yyyy') | 1029 | 'dd/MM/yyyy') |
1025 | }); | 1030 | }); |
1026 | cabeceras.push({ | 1031 | cabeceras.push({ |
1027 | label: 'Cotizacion:', | 1032 | label: 'Cotizacion:', |
1028 | valor: $filter('number')(remito.cotizacion.VENDEDOR, | 1033 | valor: $filter('number')(remito.cotizacion.VENDEDOR, |
1029 | '2') | 1034 | '2') |
1030 | }); | 1035 | }); |
1031 | } | 1036 | } |
1032 | if (remito.cliente.COD) { | 1037 | if (remito.cliente.COD) { |
1033 | cabeceras.push({ | 1038 | cabeceras.push({ |
1034 | label: 'Cliente:', | 1039 | label: 'Cliente:', |
1035 | valor: $filter('rellenarDigitos')(remito.cliente.COD, 3) + ' - ' + | 1040 | valor: $filter('rellenarDigitos')(remito.cliente.COD, 3) + ' - ' + |
1036 | remito.cliente.NOM | 1041 | remito.cliente.NOM |
1037 | }); | 1042 | }); |
1038 | cabeceras.push({ | 1043 | cabeceras.push({ |
1039 | label: 'Domicilio:', | 1044 | label: 'Domicilio:', |
1040 | valor: remito.domicilioStamp | 1045 | valor: remito.domicilioStamp |
1041 | }); | 1046 | }); |
1042 | } | 1047 | } |
1043 | if (remito.vendedor.NUM) { | 1048 | if (remito.vendedor.NUM) { |
1044 | cabeceras.push({ | 1049 | cabeceras.push({ |
1045 | label: 'Vendedor:', | 1050 | label: 'Vendedor:', |
1046 | valor: $filter('rellenarDigitos')(remito.vendedor.NUM, 3) + | 1051 | valor: $filter('rellenarDigitos')(remito.vendedor.NUM, 3) + |
1047 | ' - ' + remito.vendedor.NOM | 1052 | ' - ' + remito.vendedor.NOM |
1048 | }); | 1053 | }); |
1049 | } | 1054 | } |
1050 | if (remito.proveedor.COD) { | 1055 | if (remito.proveedor.COD) { |
1051 | cabeceras.push({ | 1056 | cabeceras.push({ |
1052 | label: 'Proveedor:', | 1057 | label: 'Proveedor:', |
1053 | valor: $filter('rellenarDigitos')(remito.proveedor.COD, 5) + | 1058 | valor: $filter('rellenarDigitos')(remito.proveedor.COD, 5) + |
1054 | ' - ' + remito.proveedor.NOM | 1059 | ' - ' + remito.proveedor.NOM |
1055 | }); | 1060 | }); |
1056 | } | 1061 | } |
1057 | if (remito.flete !== undefined && remito.fob !== undefined) { | 1062 | if (remito.flete !== undefined && remito.fob !== undefined) { |
1058 | cabeceras.push({ | 1063 | cabeceras.push({ |
1059 | label: 'Flete:', | 1064 | label: 'Flete:', |
1060 | valor: remito.fob ? 'FOB' : ( | 1065 | valor: remito.fob ? 'FOB' : ( |
1061 | remito.flete ? 'Si' : 'No') | 1066 | remito.flete ? 'Si' : 'No') |
1062 | }); | 1067 | }); |
1063 | } | 1068 | } |
1064 | if (remito.remitoPlazo) { | 1069 | if (remito.remitoPlazo) { |
1065 | cabeceras.push({ | 1070 | cabeceras.push({ |
1066 | label: 'Precio condicion:', | 1071 | label: 'Precio condicion:', |
1067 | valor: valorPrecioCondicion() + ' ' + | 1072 | valor: valorPrecioCondicion() + ' ' + |
1068 | remitoBusinessService.plazoToString(remito.remitoPlazo) | 1073 | remitoBusinessService.plazoToString(remito.remitoPlazo) |
1069 | }); | 1074 | }); |
1070 | } | 1075 | } |
1071 | function valorPrecioCondicion() { | 1076 | function valorPrecioCondicion() { |
1072 | if (remito.idPrecioCondicion > 0) { | 1077 | if (remito.idPrecioCondicion > 0) { |
1073 | return remito.precioCondicion.nombre; | 1078 | return remito.precioCondicion.nombre; |
1074 | } else { | 1079 | } else { |
1075 | return 'Ingreso Manual'; | 1080 | return 'Ingreso Manual'; |
1076 | } | 1081 | } |
1077 | } | 1082 | } |
1078 | if (remito.flete === 1) { | 1083 | if (remito.flete === 1) { |
1079 | var cabeceraBomba = { | 1084 | var cabeceraBomba = { |
1080 | label: 'Bomba', | 1085 | label: 'Bomba', |
1081 | valor: remito.bomba === 1 ? 'Si' : 'No' | 1086 | valor: remito.bomba === 1 ? 'Si' : 'No' |
1082 | }; | 1087 | }; |
1083 | if (remito.kilometros) { | 1088 | if (remito.kilometros) { |
1084 | var cabeceraKilometros = { | 1089 | var cabeceraKilometros = { |
1085 | label: 'Kilometros', | 1090 | label: 'Kilometros', |
1086 | valor: remito.kilometros | 1091 | valor: remito.kilometros |
1087 | }; | 1092 | }; |
1088 | cabeceras.push(cabeceraKilometros); | 1093 | cabeceras.push(cabeceraKilometros); |
1089 | } | 1094 | } |
1090 | cabeceras.push(cabeceraBomba); | 1095 | cabeceras.push(cabeceraBomba); |
1091 | } | 1096 | } |
1092 | 1097 | ||
1093 | if (remito.idPrecioCondicion > 0) { | 1098 | if (remito.idPrecioCondicion > 0) { |
1094 | $scope.idLista = remito.precioCondicion.idListaPrecio; | 1099 | $scope.idLista = remito.precioCondicion.idListaPrecio; |
1095 | } else { | 1100 | } else { |
1096 | $scope.idLista = -1; | 1101 | $scope.idLista = -1; |
1097 | } | 1102 | } |
1098 | $scope.puntoVenta = rellenar(remito.sucursal, 4); | 1103 | $scope.puntoVenta = rellenar(remito.sucursal, 4); |
1099 | $scope.comprobante = rellenar(remito.numeroRemito, 8); | 1104 | $scope.comprobante = rellenar(remito.numeroRemito, 8); |
1100 | $scope.remito = remito; | 1105 | $scope.remito = remito; |
1101 | if ($scope.remito.puntosDescarga) { | 1106 | if ($scope.remito.puntosDescarga) { |
1102 | var puntosDescarga = $scope.remito.puntosDescarga; | 1107 | var puntosDescarga = $scope.remito.puntosDescarga; |
1103 | cabeceras.push({ | 1108 | cabeceras.push({ |
1104 | label: 'Puntos de descarga: ', | 1109 | label: 'Puntos de descarga: ', |
1105 | valor: $filter('rellenarDigitos')(getCabeceraPuntoDescarga(puntosDescarga)) | 1110 | valor: $filter('rellenarDigitos')(getCabeceraPuntoDescarga(puntosDescarga)) |
1106 | }); | 1111 | }); |
1107 | } | 1112 | } |
1108 | addArrayCabecera(cabeceras); | 1113 | addArrayCabecera(cabeceras); |
1109 | } | 1114 | } |
1110 | 1115 | ||
1111 | function getLSRemito() { | 1116 | function getLSRemito() { |
1112 | var remito = JSON.parse($localStorage.remito || null); | 1117 | var remito = JSON.parse($localStorage.remito || null); |
1113 | if (remito) { | 1118 | if (remito) { |
1114 | setearRemito(remito); | 1119 | setearRemito(remito); |
1115 | delete $localStorage.remito; | 1120 | delete $localStorage.remito; |
1116 | } | 1121 | } |
1117 | } | 1122 | } |
1118 | 1123 | ||
1119 | function deleteCliente() { | 1124 | function deleteCliente() { |
1120 | delete $scope.remito.domicilioStamp; | 1125 | delete $scope.remito.domicilioStamp; |
1121 | delete $scope.remito.puntosDescarga; | 1126 | delete $scope.remito.puntosDescarga; |
1122 | $scope.remito.domicilio = {dom: ''}; | 1127 | $scope.remito.domicilio = {dom: ''}; |
1123 | $scope.remito.cliente = {}; | 1128 | $scope.remito.cliente = {}; |
1124 | $scope.$broadcast('removeCabecera', 'Cliente:'); | 1129 | $scope.$broadcast('removeCabecera', 'Cliente:'); |
1125 | $scope.$broadcast('removeCabecera', 'Domicilio:'); | 1130 | $scope.$broadcast('removeCabecera', 'Domicilio:'); |
1126 | $scope.$broadcast('removeCabecera', 'Puntos de descarga:'); | 1131 | $scope.$broadcast('removeCabecera', 'Puntos de descarga:'); |
1127 | } | 1132 | } |
1128 | 1133 | ||
1129 | function getCabeceraPuntoDescarga(puntosDescarga) { | 1134 | function getCabeceraPuntoDescarga(puntosDescarga) { |
1130 | var puntosStamp = ''; | 1135 | var puntosStamp = ''; |
1131 | puntosDescarga.forEach(function(punto, idx, arr) { | 1136 | puntosDescarga.forEach(function(punto, idx, arr) { |
1132 | puntosStamp += punto.descripcion; | 1137 | puntosStamp += punto.descripcion; |
1133 | if ((idx + 1) !== arr.length) puntosStamp += ', '; | 1138 | if ((idx + 1) !== arr.length) puntosStamp += ', '; |
1134 | }); | 1139 | }); |
1135 | return puntosStamp; | 1140 | return puntosStamp; |
1136 | } | 1141 | } |
1137 | 1142 | ||
1138 | function abrirModalMail(id, cliente, numeroRemito) { | 1143 | function abrirModalMail(id, cliente, numeroRemito) { |
1139 | focaModalService.mail( | 1144 | focaModalService.mail( |
1140 | { | 1145 | { |
1141 | titulo: 'Comprobante de remito Nº ' + numeroRemito, | 1146 | titulo: 'Comprobante de remito Nº ' + numeroRemito, |
1142 | descarga: { | 1147 | descarga: { |
1143 | nombre: numeroRemito + '.pdf', | 1148 | nombre: numeroRemito + '.pdf', |
1144 | url: '/remito/comprobante', | 1149 | url: '/remito/comprobante', |
1145 | }, | 1150 | }, |
1146 | envio: { | 1151 | envio: { |
1147 | mailCliente: cliente.MAIL, | 1152 | mailCliente: cliente.MAIL, |
1148 | url: '/remito/mail', | 1153 | url: '/remito/mail', |
1149 | }, | 1154 | }, |
1150 | options: { | 1155 | options: { |
1151 | idRemito: id | 1156 | idRemito: id |
1152 | } | 1157 | } |
1153 | } | 1158 | } |
1154 | ) | 1159 | ) |
1155 | .then(function(res) { | 1160 | .then(function(res) { |
1156 | if (res === false) { | 1161 | if (res === false) { |
1157 | abrirModalMail(id); | 1162 | abrirModalMail(id); |
1158 | focaModalService.alert('Descarga o envíe su remito ' + | 1163 | focaModalService.alert('Descarga o envíe su remito ' + |
1159 | 'antes de cerrar esta ventana'); | 1164 | 'antes de cerrar esta ventana'); |
1160 | } | 1165 | } |
1161 | }); | 1166 | }); |
1162 | } | 1167 | } |
1168 | //recibo la propiedad por la cual quiero obtener el valor | ||
1169 | function getImporte(propiedad) { | ||
1170 | var importe = 0; | ||
1171 | |||
1172 | $scope.articulosFiltro().forEach(function (articulo) { | ||
1173 | |||
1174 | if (articulo[propiedad]) { | ||
1175 | importe += articulo[propiedad] * articulo.cantidad; | ||
1176 | } | ||
1177 | return; | ||
1178 | |||
1179 | }); | ||
1180 | |||
1181 | return importe; | ||
1182 | } | ||
1163 | } | 1183 | } |
1164 | ]); | 1184 | ]); |
1165 | 1185 |
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 | <marquee | 9 | <marquee |
10 | bgcolor="#FF9900" | 10 | bgcolor="#FF9900" |
11 | behavior="scroll" | 11 | behavior="scroll" |
12 | direction="left" | 12 | direction="left" |
13 | ng-bind="remito.observaciones" | 13 | ng-bind="remito.observaciones" |
14 | ></marquee> | 14 | ></marquee> |
15 | <div class="col-lg-12"> | 15 | <div class="col-lg-12"> |
16 | <div class="row mt-4"> | 16 | <div class="row mt-4"> |
17 | <div class="col-12 col-md-10 col-lg-10 border border-light rounded"> | 17 | <div class="col-12 col-md-10 col-lg-10 border border-light rounded"> |
18 | <div class="row p-1 botonera-secundaria px-5 py-2"> | 18 | <div class="row p-1 botonera-secundaria px-5 py-2"> |
19 | <div class="col-12"> | 19 | <div class="col-12"> |
20 | <foca-botonera-facturador botones="botonera" extra="4" class="row"></foca-botonera-facturador> | 20 | <foca-botonera-facturador botones="botonera" extra="4" class="row"></foca-botonera-facturador> |
21 | </div> | 21 | </div> |
22 | </div> | 22 | </div> |
23 | <!-- PC --> | 23 | <!-- PC --> |
24 | <div class="row grilla-articulo align-items-end d-none d-sm-flex"> | 24 | <div class="row grilla-articulo align-items-end d-none d-sm-flex"> |
25 | <table class="table tabla-articulo table-striped table-sm mb-0 rounded-bottom"> | 25 | <table class="table tabla-articulo table-striped table-sm mb-0 rounded-bottom"> |
26 | <thead> | 26 | <thead> |
27 | <tr class="d-flex"> | 27 | <tr class="d-flex"> |
28 | <th class="">#</th> | 28 | <th class="">#</th> |
29 | <th class="col">Código</th> | 29 | <th class="col">Código</th> |
30 | <th class="col-4">Descripción</th> | 30 | <th class="col-4">Descripción</th> |
31 | <th class="col text-right">Cantidad</th> | 31 | <th class="col text-right">Cantidad</th> |
32 | <th class="col text-right">Precio Unitario</th> | 32 | <th class="col text-right">Precio Unitario</th> |
33 | <th class="col text-right">SubTotal</th> | 33 | <th class="col text-right">SubTotal</th> |
34 | <th class="text-right"> | 34 | <th class="text-right"> |
35 | <button | 35 | <button |
36 | class="btn btn-outline-light selectable" | 36 | class="btn btn-outline-light selectable" |
37 | ng-click="show = !show; masMenos()" | 37 | ng-click="show = !show; masMenos()" |
38 | > | 38 | > |
39 | <i | 39 | <i |
40 | class="fa fa-chevron-down" | 40 | class="fa fa-chevron-down" |
41 | ng-show="show" | 41 | ng-show="show" |
42 | aria-hidden="true" | 42 | aria-hidden="true" |
43 | > | 43 | > |
44 | </i> | 44 | </i> |
45 | <i | 45 | <i |
46 | class="fa fa-chevron-up" | 46 | class="fa fa-chevron-up" |
47 | ng-hide="show" | 47 | ng-hide="show" |
48 | aria-hidden="true"> | 48 | aria-hidden="true"> |
49 | </i> | 49 | </i> |
50 | </button> | 50 | </button> |
51 | </th> | 51 | </th> |
52 | </tr> | 52 | </tr> |
53 | </thead> | 53 | </thead> |
54 | <tbody class="tabla-articulo-body"> | 54 | <tbody class="tabla-articulo-body"> |
55 | <tr | 55 | <tr |
56 | ng-repeat="(key, articulo) in articulosFiltro()" | 56 | ng-repeat="(key, articulo) in articulosFiltro()" |
57 | ng-show="show || key == (articulosFiltro().length - 1)" | 57 | ng-show="show || key == (articulosFiltro().length - 1)" |
58 | class="d-flex" | 58 | class="d-flex" |
59 | > | 59 | > |
60 | <td ng-bind="key + 1"></td> | 60 | <td ng-bind="key + 1"></td> |
61 | <td | 61 | <td |
62 | class="col" | 62 | class="col" |
63 | ng-bind="articulo.sector + '-' + articulo.codigo" | 63 | ng-bind="articulo.sector + '-' + articulo.codigo" |
64 | ></td> | 64 | ></td> |
65 | <td | 65 | <td |
66 | class="col-4" | 66 | class="col-4" |
67 | ng-bind="articulo.descripcion" | 67 | ng-bind="articulo.descripcion" |
68 | ></td> | 68 | ></td> |
69 | <td class="col text-right"> | 69 | <td class="col text-right"> |
70 | <input | 70 | <input |
71 | ng-show="articulo.editCantidad" | 71 | ng-show="articulo.editCantidad" |
72 | ng-model="tmpCantidad" | 72 | ng-model="tmpCantidad" |
73 | class="form-control" | 73 | class="form-control" |
74 | foca-tipo-input | 74 | foca-tipo-input |
75 | min="1" | 75 | min="1" |
76 | foca-focus="articulo.editCantidad" | 76 | foca-focus="articulo.editCantidad" |
77 | ng-keypress="editarArticulo($event.keyCode, articulo, tmpCantidad, tmpPrecio);" | 77 | ng-keypress="editarArticulo($event.keyCode, articulo, tmpCantidad, tmpPrecio);" |
78 | esc-key="cancelarEditar(articulo)" | 78 | esc-key="cancelarEditar(articulo)" |
79 | ng-focus="selectFocus($event); | 79 | ng-focus="selectFocus($event); |
80 | tmpCantidad = articulo.cantidad; | 80 | tmpCantidad = articulo.cantidad; |
81 | tmpPrecio = articulo.precio" | 81 | tmpPrecio = articulo.precio" |
82 | teclado-virtual | 82 | teclado-virtual |
83 | > | 83 | > |
84 | <i | 84 | <i |
85 | class="selectable" | 85 | class="selectable" |
86 | ng-click="cambioEdit(articulo, 'cantidad')" | 86 | ng-click="cambioEdit(articulo, 'cantidad')" |
87 | ng-hide="articulo.editCantidad" | 87 | ng-hide="articulo.editCantidad" |
88 | ng-bind="articulo.cantidad"> | 88 | ng-bind="articulo.cantidad"> |
89 | </i> | 89 | </i> |
90 | </td> | 90 | </td> |
91 | <td class="col text-right"> | 91 | <td class="col text-right"> |
92 | <input | 92 | <input |
93 | ng-show="articulo.editPrecio" | 93 | ng-show="articulo.editPrecio" |
94 | ng-model="tmpPrecio" | 94 | ng-model="tmpPrecio" |
95 | class="form-control" | 95 | class="form-control" |
96 | foca-tipo-input | 96 | foca-tipo-input |
97 | min="1" | 97 | min="1" |
98 | step="0.0001" | 98 | step="0.0001" |
99 | foca-focus="articulo.editPrecio" | 99 | foca-focus="articulo.editPrecio" |
100 | ng-keypress="editarArticulo($event.keyCode, articulo, tmpCantidad, tmpPrecio);" | 100 | ng-keypress="editarArticulo($event.keyCode, articulo, tmpCantidad, tmpPrecio);" |
101 | esc-key="cancelarEditar(articulo)" | 101 | esc-key="cancelarEditar(articulo)" |
102 | ng-focus="selectFocus($event); | 102 | ng-focus="selectFocus($event); |
103 | tmpCantidad = articulo.cantidad; | 103 | tmpCantidad = articulo.cantidad; |
104 | tmpPrecio = articulo.precio" | 104 | tmpPrecio = articulo.precio" |
105 | teclado-virtual | 105 | teclado-virtual |
106 | > | 106 | > |
107 | <i | 107 | <i |
108 | class="selectable" | 108 | class="selectable" |
109 | ng-click="cambioEdit(articulo, 'precio')" | 109 | ng-click="cambioEdit(articulo, 'precio')" |
110 | ng-hide="articulo.editPrecio" | 110 | ng-hide="articulo.editPrecio" |
111 | ng-bind="articulo.precio | number: 4"> | 111 | ng-bind="articulo.precio | number: 4"> |
112 | </i> | 112 | </i> |
113 | </td> | 113 | </td> |
114 | <td | 114 | <td |
115 | class="col text-right" | 115 | class="col text-right" |
116 | ng-bind="(articulo.precio * articulo.cantidad) | number: 2"> | 116 | ng-bind="(articulo.precio * articulo.cantidad) | number: 2"> |
117 | </td> | 117 | </td> |
118 | <td class="text-center"> | 118 | <td class="text-center"> |
119 | <button | 119 | <button |
120 | class="btn btn-outline-light" | 120 | class="btn btn-outline-light" |
121 | ng-click="quitarArticulo(articulo)" | 121 | ng-click="quitarArticulo(articulo)" |
122 | > | 122 | > |
123 | <i class="fa fa-trash"></i> | 123 | <i class="fa fa-trash"></i> |
124 | </button> | 124 | </button> |
125 | <button | 125 | <button |
126 | class="btn btn-outline-light" | 126 | class="btn btn-outline-light" |
127 | ng-click="editarArticulo(13, articulo)" | 127 | ng-click="editarArticulo(13, articulo)" |
128 | ng-show="articulo.editCantidad || articulo.editPrecio" | 128 | ng-show="articulo.editCantidad || articulo.editPrecio" |
129 | > | 129 | > |
130 | <i class="fa fa-save"></i> | 130 | <i class="fa fa-save"></i> |
131 | </button> | 131 | </button> |
132 | </td> | 132 | </td> |
133 | </tr> | 133 | </tr> |
134 | </tbody> | 134 | </tbody> |
135 | <tfoot> | 135 | <tfoot> |
136 | <tr ng-show="!cargando" class="d-flex"> | 136 | <tr ng-show="!cargando" class="d-flex"> |
137 | <td | 137 | <td |
138 | class="align-middle" | 138 | class="align-middle" |
139 | ng-bind="articulosFiltro().length + 1" | 139 | ng-bind="articulosFiltro().length + 1" |
140 | ></td> | 140 | ></td> |
141 | <td class="col"> | 141 | <td class="col"> |
142 | <input | 142 | <input |
143 | class="form-control" | 143 | class="form-control" |
144 | ng-model="articuloACargar.sectorCodigo" | 144 | ng-model="articuloACargar.sectorCodigo" |
145 | readonly | 145 | readonly |
146 | > | 146 | > |
147 | </td> | 147 | </td> |
148 | <td class="col-4 tabla-articulo-descripcion"> | 148 | <td class="col-4 tabla-articulo-descripcion"> |
149 | <input | 149 | <input |
150 | class="form-control" | 150 | class="form-control" |
151 | ng-model="articuloACargar.descripcion" | 151 | ng-model="articuloACargar.descripcion" |
152 | readonly | 152 | readonly |
153 | > | 153 | > |
154 | </td> | 154 | </td> |
155 | <td class="col text-right"> | 155 | <td class="col text-right"> |
156 | <input | 156 | <input |
157 | class="form-control" | 157 | class="form-control" |
158 | foca-tipo-input | 158 | foca-tipo-input |
159 | min="1" | 159 | min="1" |
160 | ng-model="articuloACargar.cantidad" | 160 | ng-model="articuloACargar.cantidad" |
161 | foca-focus="!cargando" | 161 | foca-focus="!cargando" |
162 | esc-key="resetFilter()" | 162 | esc-key="resetFilter()" |
163 | ng-keypress="agregarATabla($event.keyCode)" | 163 | ng-keypress="agregarATabla($event.keyCode)" |
164 | teclado-virtual | 164 | teclado-virtual |
165 | > | 165 | > |
166 | </td> | 166 | </td> |
167 | <td class="col text-right"> | 167 | <td class="col text-right"> |
168 | <input | 168 | <input |
169 | class="form-control" | 169 | class="form-control" |
170 | ng-model="articuloACargar.precio" | 170 | ng-model="articuloACargar.precio" |
171 | ng-show="idLista != -1" | 171 | ng-show="idLista != -1" |
172 | ng-keypress="agregarATabla($event.keyCode)" | 172 | ng-keypress="agregarATabla($event.keyCode)" |
173 | > | 173 | > |
174 | <input | 174 | <input |
175 | class="form-control" | 175 | class="form-control" |
176 | foca-tipo-input | 176 | foca-tipo-input |
177 | step="0.0001" | 177 | step="0.0001" |
178 | ng-model="articuloACargar.precio" | 178 | ng-model="articuloACargar.precio" |
179 | esc-key="resetFilter()" | 179 | esc-key="resetFilter()" |
180 | ng-keypress="agregarATabla($event.keyCode)" | 180 | ng-keypress="agregarATabla($event.keyCode)" |
181 | ng-show="idLista == -1" | 181 | ng-show="idLista == -1" |
182 | teclado-virtual | 182 | teclado-virtual |
183 | > | 183 | > |
184 | </td> | 184 | </td> |
185 | <td class="col text-right"> | 185 | <td class="col text-right"> |
186 | <input | 186 | <input |
187 | class="form-control" | 187 | class="form-control" |
188 | ng-value="getSubTotal() | number: 2" | 188 | ng-value="getSubTotal() | number: 2" |
189 | readonly | 189 | readonly |
190 | ></td> | 190 | ></td> |
191 | <td class="text-center align-middle"> | 191 | <td class="text-center align-middle"> |
192 | <button | 192 | <button |
193 | class="btn btn-outline-light" | 193 | class="btn btn-outline-light" |
194 | ng-click="agregarATabla(13)" | 194 | ng-click="agregarATabla(13)" |
195 | > | 195 | > |
196 | <i class="fa fa-save"></i> | 196 | <i class="fa fa-save"></i> |
197 | </button> | 197 | </button> |
198 | </td> | 198 | </td> |
199 | </tr> | 199 | </tr> |
200 | 200 | ||
201 | <tr class="d-flex"> | 201 | <tr class="d-flex"> |
202 | <td colspan="4" class="no-border-top"> | 202 | <td colspan="4" class="no-border-top"> |
203 | <strong>Items:</strong> | 203 | <strong>Items:</strong> |
204 | <a ng-bind="articulosFiltro().length"></a> | 204 | <a ng-bind="articulosFiltro().length"></a> |
205 | </td> | 205 | </td> |
206 | <td class="text-right ml-auto table-celda-total no-border-top"> | 206 | <td class="text-right ml-auto table-celda-total no-border-top"> |
207 | <h3>Total:</h3> | 207 | <h3>Total:</h3> |
208 | </td> | 208 | </td> |
209 | <td class="table-celda-total text-right no-border-top" colspan="1"> | 209 | <td class="table-celda-total text-right no-border-top" colspan="1"> |
210 | <h3>{{getTotal() | currency: remito.cotizacion.moneda.SIMBOLO}}</h3> | 210 | <h3>{{getTotal() | currency: remito.cotizacion.moneda.SIMBOLO}}</h3> |
211 | </td> | 211 | </td> |
212 | <td class="text-right no-border-top"> | 212 | <td class="text-right no-border-top"> |
213 | <button | 213 | <button |
214 | type="button" | 214 | type="button" |
215 | class="btn btn-default btn-sm" | 215 | class="btn btn-sm" |
216 | > | 216 | > |
217 | Totales | 217 | Totales |
218 | </button> | 218 | </button> |
219 | </td> | 219 | </td> |
220 | </tr> | 220 | </tr> |
221 | </tfoot> | 221 | </tfoot> |
222 | </table> | 222 | </table> |
223 | </div> | 223 | </div> |
224 | </div> | 224 | </div> |
225 | </div> | 225 | </div> |
226 | </div> | 226 | </div> |
227 | <div class="row d-md-none fixed-bottom"> | 227 | <div class="row d-md-none fixed-bottom"> |
228 | <div class="w-100 bg-dark d-flex px-3 acciones-mobile"> | 228 | <div class="w-100 bg-dark d-flex px-3 acciones-mobile"> |
229 | <span class="ml-3 text-muted" ng-click="salir()">Salir</span> | 229 | <span class="ml-3 text-muted" ng-click="salir()">Salir</span> |
230 | <span | 230 | <span |
231 | class="mr-3 ml-auto" | 231 | class="mr-3 ml-auto" |
232 | ng-class="saveLoading ? 'text-muted' : ''" | 232 | ng-class="saveLoading ? 'text-muted' : ''" |
233 | ng-click="crearRemito()" | 233 | ng-click="crearRemito()" |
234 | ladda="saveLoading" | 234 | ladda="saveLoading" |
235 | data-style="expand-left" | 235 | data-style="expand-left" |
236 | >Guardar</span> | 236 | >Guardar</span> |
237 | </div> | 237 | </div> |
238 | </div> | 238 | </div> |
239 | </div> | 239 | </div> |
240 | 240 |