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