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