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