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