Commit f7d8103185827253e5cd9f52bc6e5604a5107c3b
1 parent
c396f04d4b
Exists in
master
forma de pago
Showing
2 changed files
with
14 additions
and
4 deletions
Show diff stats
src/js/controller.js
1 | angular.module('focaCrearFactura').controller('facturaController', [ | 1 | angular.module('focaCrearFactura').controller('facturaController', [ |
2 | '$scope', '$uibModal', '$location', '$filter', 'crearFacturaService', '$timeout', | 2 | '$scope', '$uibModal', '$location', '$filter', 'crearFacturaService', '$timeout', |
3 | 'focaModalService', 'crearRemitoService', '$rootScope', 'focaBotoneraLateralService', | 3 | 'focaModalService', 'crearRemitoService', '$rootScope', 'focaBotoneraLateralService', |
4 | '$localStorage', 'APP', 'focaLoginService', | 4 | '$localStorage', 'APP', 'focaLoginService', |
5 | function ( | 5 | function ( |
6 | $scope, $uibModal, $location, $filter, crearFacturaService, $timeout, focaModalService, | 6 | $scope, $uibModal, $location, $filter, crearFacturaService, $timeout, focaModalService, |
7 | crearRemitoService, $rootScope, focaBotoneraLateralService, $localStorage, APP, loginServ) { | 7 | crearRemitoService, $rootScope, focaBotoneraLateralService, $localStorage, APP, loginServ) { |
8 | 8 | ||
9 | config(); | 9 | config(); |
10 | 10 | ||
11 | function config() { | 11 | function config() { |
12 | $scope.tmpCantidad = '0'; | 12 | $scope.tmpCantidad = '0'; |
13 | $scope.botonera = crearFacturaService.getBotonera(); | 13 | $scope.botonera = crearFacturaService.getBotonera(); |
14 | $scope.botoneraProductos = []; | 14 | $scope.botoneraProductos = []; |
15 | $scope.isNumber = angular.isNumber; | 15 | $scope.isNumber = angular.isNumber; |
16 | $scope.datepickerAbierto = false; | 16 | $scope.datepickerAbierto = false; |
17 | $scope.show = false; | 17 | $scope.show = false; |
18 | $scope.cargando = true; | 18 | $scope.cargando = true; |
19 | $scope.now = new Date(); | 19 | $scope.now = new Date(); |
20 | $scope.puntoVenta = rellenar(0, 4); | 20 | $scope.puntoVenta = rellenar(0, 4); |
21 | $scope.comprobante = rellenar(0, 8); | 21 | $scope.comprobante = rellenar(0, 8); |
22 | $scope.dateOptions = { | 22 | $scope.dateOptions = { |
23 | maxDate: new Date(), | 23 | maxDate: new Date(), |
24 | minDate: new Date(2010, 0, 1) | 24 | minDate: new Date(2010, 0, 1) |
25 | }; | 25 | }; |
26 | $scope.cabeceras = []; | 26 | $scope.cabeceras = []; |
27 | crearFacturaService.getParametros().then(function (res) { | 27 | crearFacturaService.getParametros().then(function (res) { |
28 | 28 | ||
29 | var parametros = JSON.parse(res.data[0].jsonText); | 29 | var parametros = JSON.parse(res.data[0].jsonText); |
30 | 30 | ||
31 | if ($localStorage.factura) { | 31 | if ($localStorage.factura) { |
32 | 32 | ||
33 | $timeout(function () { getLSFactura(); }); | 33 | $timeout(function () { getLSFactura(); }); |
34 | } else { | 34 | } else { |
35 | 35 | ||
36 | for (var property in parametros) { | 36 | for (var property in parametros) { |
37 | $scope.factura[property] = parametros[property]; | 37 | $scope.factura[property] = parametros[property]; |
38 | $scope.inicial[property] = parametros[property]; | 38 | $scope.inicial[property] = parametros[property]; |
39 | } | 39 | } |
40 | 40 | ||
41 | setearFactura($scope.factura); | 41 | setearFactura($scope.factura); |
42 | } | 42 | } |
43 | 43 | ||
44 | }); | 44 | }); |
45 | 45 | ||
46 | //SETEO BOTONERA LATERAL | 46 | //SETEO BOTONERA LATERAL |
47 | $timeout(function () { | 47 | $timeout(function () { |
48 | focaBotoneraLateralService.showSalir(false); | 48 | focaBotoneraLateralService.showSalir(false); |
49 | focaBotoneraLateralService.showPausar(true); | 49 | focaBotoneraLateralService.showPausar(true); |
50 | focaBotoneraLateralService.showGuardar(true, $scope.seleccionarFormaDePago); | 50 | focaBotoneraLateralService.showGuardar(true, $scope.seleccionarFormaDePago); |
51 | focaBotoneraLateralService.addCustomButton('Salir', $scope.salir); | 51 | focaBotoneraLateralService.addCustomButton('Salir', $scope.salir); |
52 | }); | 52 | }); |
53 | 53 | ||
54 | init(); | 54 | init(); |
55 | 55 | ||
56 | } | 56 | } |
57 | 57 | ||
58 | function init() { | 58 | function init() { |
59 | 59 | ||
60 | $scope.$broadcast('cleanCabecera'); | 60 | $scope.$broadcast('cleanCabecera'); |
61 | 61 | ||
62 | $scope.factura = { | 62 | $scope.factura = { |
63 | id: 0, | 63 | id: 0, |
64 | estado: 0, | 64 | estado: 0, |
65 | vendedor: {}, | 65 | vendedor: {}, |
66 | cliente: {}, | 66 | cliente: {}, |
67 | proveedor: {}, | 67 | proveedor: {}, |
68 | domicilio: { dom: '' }, | 68 | domicilio: { dom: '' }, |
69 | moneda: {}, | 69 | moneda: {}, |
70 | formaPago: 1, // Por defecto paga contado | ||
70 | cotizacion: $scope.cotizacionPorDefecto || {}, | 71 | cotizacion: $scope.cotizacionPorDefecto || {}, |
71 | articulosFactura: [], | 72 | articulosFactura: [], |
72 | despachos: [] | 73 | despachos: [] |
73 | }; | 74 | }; |
74 | 75 | ||
75 | $scope.factura.articulosFactura = []; | 76 | $scope.factura.articulosFactura = []; |
76 | $scope.idLista = undefined; | 77 | $scope.idLista = undefined; |
77 | 78 | ||
78 | crearRemitoService.getNumeroRemito().then( | 79 | crearRemitoService.getNumeroRemito().then( |
79 | function (res) { | 80 | function (res) { |
80 | $scope.puntoVenta = rellenar(res.data.sucursal, 4); | 81 | $scope.puntoVenta = rellenar(res.data.sucursal, 4); |
81 | $scope.comprobante = rellenar(res.data.numeroRemito, 8); | 82 | $scope.comprobante = rellenar(res.data.numeroRemito, 8); |
82 | }, | 83 | }, |
83 | function (err) { | 84 | function (err) { |
84 | focaModalService.alert('La terminal no esta configurada correctamente'); | 85 | focaModalService.alert('La terminal no esta configurada correctamente'); |
85 | console.info(err); | 86 | console.info(err); |
86 | } | 87 | } |
87 | ); | 88 | ); |
88 | 89 | ||
89 | $scope.inicial = angular.copy($scope.factura); | 90 | $scope.inicial = angular.copy($scope.factura); |
90 | 91 | ||
91 | if (APP == 'facturador') { | 92 | if (APP == 'facturador') { |
92 | crearFacturaService | 93 | crearFacturaService |
93 | .getVendedorPlayaById(loginServ.getLoginData().vendedorPlaya) | 94 | .getVendedorPlayaById(loginServ.getLoginData().vendedorPlaya) |
94 | .then(function (res) { | 95 | .then(function (res) { |
95 | 96 | ||
96 | validarPlanillaVendedor(res.data) | 97 | validarPlanillaVendedor(res.data) |
97 | .then(function () { | 98 | .then(function () { |
98 | 99 | ||
99 | $scope.$broadcast('addCabecera', { | 100 | $scope.$broadcast('addCabecera', { |
100 | label: 'Vendedor:', | 101 | label: 'Vendedor:', |
101 | valor: $filter('rellenarDigitos')(res.data.CodVen, 3) + | 102 | valor: $filter('rellenarDigitos')(res.data.CodVen, 3) + |
102 | ' - ' + | 103 | ' - ' + |
103 | res.data.NomVen | 104 | res.data.NomVen |
104 | }); | 105 | }); |
105 | 106 | ||
106 | $scope.factura.vendedor = res.data; | 107 | $scope.factura.vendedor = res.data; |
107 | $scope.inicial.vendedor = res.data; | 108 | $scope.inicial.vendedor = res.data; |
108 | 109 | ||
109 | getProductosByPlanilla(res.data.NplVen); | 110 | getProductosByPlanilla(res.data.NplVen); |
110 | }) | 111 | }) |
111 | .catch(function (err) { | 112 | .catch(function (err) { |
112 | console.log(err); | 113 | console.log(err); |
113 | focaModalService.alert('Ocurrió un error al intentar recuperar' + | 114 | focaModalService.alert('Ocurrió un error al intentar recuperar' + |
114 | 'el vendedor logeado'); | 115 | 'el vendedor logeado'); |
115 | }); | 116 | }); |
116 | }) | 117 | }) |
117 | } | 118 | } |
118 | } | 119 | } |
119 | 120 | ||
120 | $scope.$watch('factura', function (newValue) { | 121 | $scope.$watch('factura', function (newValue) { |
121 | focaBotoneraLateralService.setPausarData({ | 122 | focaBotoneraLateralService.setPausarData({ |
122 | label: 'factura', | 123 | label: 'factura', |
123 | val: newValue | 124 | val: newValue |
124 | }); | 125 | }); |
125 | }, true); | 126 | }, true); |
126 | 127 | ||
127 | $scope.seleccionarFormaDePago = function () { | 128 | $scope.seleccionarFormaDePago = function () { |
129 | |||
128 | if (!validarGuardar()) return; | 130 | if (!validarGuardar()) return; |
131 | |||
132 | if ($scope.factura.formaPago == 2) { | ||
133 | $scope.crearFactura(); | ||
134 | return; | ||
135 | } | ||
136 | |||
129 | var modalInstance = $uibModal.open( | 137 | var modalInstance = $uibModal.open( |
130 | { | 138 | { |
131 | templateUrl: 'modal-forma-pago.html', | 139 | templateUrl: 'modal-forma-pago.html', |
132 | controller: 'focaModalFormaPagoController', | 140 | controller: 'focaModalFormaPagoController', |
133 | resolve: { | 141 | resolve: { |
134 | parametros: function () { | 142 | parametros: function () { |
135 | return { | 143 | return { |
136 | importe: $scope.getTotal() | 144 | importe: $scope.getTotal() |
137 | }; | 145 | }; |
138 | }, | 146 | }, |
139 | }, | 147 | }, |
140 | size: 'lg', | 148 | size: 'lg', |
141 | } | 149 | } |
142 | ); | 150 | ); |
143 | modalInstance.result | 151 | modalInstance.result |
144 | .then(function (data) { | 152 | .then(function (data) { |
145 | 153 | ||
146 | $scope.crearFactura(data); | 154 | $scope.crearFactura(data); |
147 | }) | 155 | }) |
148 | .catch(function (e) { console.error(e); }); | 156 | .catch(function (e) { console.error(e); }); |
149 | }; | 157 | }; |
150 | 158 | ||
151 | $scope.crearFactura = function (formaPago) { | 159 | $scope.crearFactura = function (formaPago) { |
152 | 160 | ||
153 | var save = { | 161 | var save = { |
154 | factura: { | 162 | factura: { |
155 | 163 | ||
156 | BONIF: 0, | 164 | BONIF: 0, |
157 | CLI: $scope.factura.cliente.cod, | 165 | CLI: $scope.factura.cliente.cod, |
158 | CUI: $scope.factura.cliente.cuit, | 166 | CUI: $scope.factura.cliente.cuit, |
159 | CTA: $scope.factura.cliente.cod, | 167 | CTA: $scope.factura.cliente.cod, |
160 | DC1: '', | 168 | DC1: '', |
161 | DC2: '', | 169 | DC2: '', |
162 | DE1: '', | 170 | DE1: '', |
163 | DOM: $scope.factura.cliente.DOM, | 171 | DOM: $scope.factura.cliente.DOM, |
164 | FACAUT: 0, | 172 | FACAUT: 0, |
165 | DTO: 0, | 173 | DTO: 0, |
166 | FEC: $filter('date')($scope.now, 'yyyy-MM-dd HH:mm:ss'), | 174 | FEC: $filter('date')($scope.now, 'yyyy-MM-dd HH:mm:ss'), |
167 | FEC_ANT: '19000101', | 175 | FEC_ANT: '19000101', |
168 | FPA: 0, // 0 <- Múltiple formas de pago, 2 cta corriente | 176 | FPA: $scope.factura.formaPago, |
169 | IDEXCEPCION: 0, | 177 | IDEXCEPCION: 0, |
170 | IDLP: $scope.factura.cliente.mod.trim() || 0, | 178 | IDLP: $scope.factura.cliente.mod.trim() || 0, |
171 | IDPERSONERIA: 0, | 179 | IDPERSONERIA: 0, |
172 | IMI: 0, // TODO | 180 | IMI: 0, // TODO |
173 | IMI2: 0, // TODO | 181 | IMI2: 0, // TODO |
174 | IMI3: 0, // TODO | 182 | IMI3: 0, // TODO |
175 | IMP_LEY: 0, | 183 | IMP_LEY: 0, |
176 | IRI: 0, // TODO | 184 | IRI: 0, // TODO |
177 | IRS: 0, | 185 | IRS: 0, |
178 | LEG: '', | 186 | LEG: '', |
179 | LUG: $scope.factura.vendedor.LugVen, | 187 | LUG: $scope.factura.vendedor.LugVen, |
180 | MK_M: 0, | 188 | MK_M: 0, |
181 | NEE: 0, // TODO | 189 | NEE: 0, // TODO |
182 | NET: 0, // TODO | 190 | NET: 0, // TODO |
183 | NFI: '', | 191 | NFI: '', |
184 | NNP: 0, | 192 | NNP: 0, |
185 | NOM: $scope.factura.cliente.nom, | 193 | NOM: $scope.factura.cliente.nom, |
186 | OPE: $scope.factura.vendedor.CodVen, | 194 | OPE: $scope.factura.vendedor.CodVen, |
187 | PAG: $scope.getTotal(), | 195 | PAG: $scope.getTotal(), |
188 | PER: 0, | 196 | PER: 0, |
189 | PER_IVA: 0, | 197 | PER_IVA: 0, |
190 | PLA: $scope.factura.vendedor.NplVen, | 198 | PLA: $scope.factura.vendedor.NplVen, |
191 | PRO: '', | 199 | PRO: '', |
192 | REC_ANT: 0, | 200 | REC_ANT: 0, |
193 | SUC: parseInt($scope.puntoVenta), | 201 | SUC: parseInt($scope.puntoVenta), |
194 | TCA: 1, | 202 | TCA: 1, |
195 | TCO: 'FT', | 203 | TCO: 'FT', |
196 | TFI: '', | 204 | TFI: '', |
197 | TIP: $scope.factura.cliente.tipoFactura, | 205 | TIP: $scope.factura.cliente.tipoFactura, |
198 | TIV: 0, // TODO | 206 | TIV: 0, // TODO |
199 | TOT: $scope.getTotal(), | 207 | TOT: $scope.getTotal(), |
200 | TUR: 0, // TODO | 208 | TUR: 0, // TODO |
201 | VEN: $scope.factura.vendedor.CodVen, | 209 | VEN: $scope.factura.vendedor.CodVen, |
202 | VTO_CLI: '', | 210 | VTO_CLI: '', |
203 | ZON: 1, // TODO | 211 | ZON: 1, // TODO |
204 | OBSERVACIONES: $scope.factura.observaciones | 212 | OBSERVACIONES: $scope.factura.observaciones |
205 | }, | 213 | }, |
206 | cuerpo: $scope.articulosFiltro(), | 214 | cuerpo: $scope.articulosFiltro(), |
207 | despachos: $scope.factura.despachos, | 215 | despachos: $scope.factura.despachos, |
208 | formaPago: formaPago | 216 | formaPago: formaPago |
209 | }; | 217 | }; |
210 | 218 | ||
211 | crearFacturaService.guardarFactura(save).then(function (res) { | 219 | crearFacturaService.guardarFactura(save).then(function (res) { |
212 | 220 | ||
213 | focaBotoneraLateralService.endGuardar(true); | 221 | focaBotoneraLateralService.endGuardar(true); |
214 | 222 | ||
215 | focaModalService.alert('Comprobante guardado con éxito'); | 223 | focaModalService.alert('Comprobante guardado con éxito'); |
216 | 224 | ||
217 | config(); | 225 | config(); |
218 | 226 | ||
219 | }).catch(function (err) { | 227 | }).catch(function (err) { |
220 | focaModalService.alert('Hubo un error al guardar la factura'); | 228 | focaModalService.alert('Hubo un error al guardar la factura'); |
221 | console.error(err); | 229 | console.error(err); |
222 | }); | 230 | }); |
223 | 231 | ||
224 | }; | 232 | }; |
225 | 233 | ||
226 | $scope.seleccionarCliente = function () { | 234 | $scope.seleccionarCliente = function () { |
227 | 235 | ||
228 | var modalInstance = $uibModal.open( | 236 | var modalInstance = $uibModal.open( |
229 | { | 237 | { |
230 | ariaLabelledBy: 'Busqueda de Cliente', | 238 | ariaLabelledBy: 'Busqueda de Cliente', |
231 | templateUrl: 'foca-busqueda-cliente-modal.html', | 239 | templateUrl: 'foca-busqueda-cliente-modal.html', |
232 | controller: 'focaBusquedaClienteModalController', | 240 | controller: 'focaBusquedaClienteModalController', |
233 | resolve: { | 241 | resolve: { |
234 | vendedor: function () { return null; }, | 242 | vendedor: function () { return null; }, |
235 | cobrador: function () { return null; } | 243 | cobrador: function () { return null; } |
236 | }, | 244 | }, |
237 | size: 'lg' | 245 | size: 'lg' |
238 | } | 246 | } |
239 | ); | 247 | ); |
240 | modalInstance.result.then( | 248 | modalInstance.result.then( |
241 | function (cliente) { | 249 | function (cliente) { |
242 | var modalInstance = $uibModal.open( | 250 | var modalInstance = $uibModal.open( |
243 | { | 251 | { |
244 | templateUrl: 'modal-estado-cuenta.html', | 252 | templateUrl: 'modal-estado-cuenta.html', |
245 | controller: 'focaModalEstadoCuentaController', | 253 | controller: 'focaModalEstadoCuentaController', |
246 | size: 'lg', | 254 | size: 'lg', |
247 | resolve: { | 255 | resolve: { |
248 | parametros: function () { return { idCliente: cliente.cod }; }, | 256 | parametros: function () { return { idCliente: cliente.cod }; }, |
249 | } | 257 | } |
250 | } | 258 | } |
251 | ); | 259 | ); |
252 | modalInstance.result | 260 | modalInstance.result |
253 | .then(function (data) { | 261 | .then(function (data) { |
254 | 262 | ||
263 | $scope.factura.formaPago = data.formaDePago; | ||
264 | |||
255 | $scope.factura.cliente = cliente; | 265 | $scope.factura.cliente = cliente; |
256 | 266 | ||
257 | $scope.$broadcast('addCabecera', { | 267 | $scope.$broadcast('addCabecera', { |
258 | label: 'Cliente:', | 268 | label: 'Cliente:', |
259 | valor: $filter('rellenarDigitos')(cliente.cod, 3) + | 269 | valor: $filter('rellenarDigitos')(cliente.cod, 3) + |
260 | ' - ' + cliente.nom | 270 | ' - ' + cliente.nom |
261 | }); | 271 | }); |
262 | 272 | ||
263 | $filter('filter')($scope.botonera, | 273 | $filter('filter')($scope.botonera, |
264 | { label: 'Cliente' })[0].checked = true; | 274 | { label: 'Cliente' })[0].checked = true; |
265 | 275 | ||
266 | $scope.$broadcast('addCabecera', { | 276 | $scope.$broadcast('addCabecera', { |
267 | label: 'Tipo de pago: ', | 277 | label: 'Tipo de pago: ', |
268 | valor: data | 278 | valor: data.tipo |
269 | }); | 279 | }); |
270 | }) | 280 | }) |
271 | .catch(function () { | 281 | .catch(function () { |
272 | 282 | ||
273 | $scope.seleccionarCliente(); | 283 | $scope.seleccionarCliente(); |
274 | }); | 284 | }); |
275 | 285 | ||
276 | }, function () { | 286 | }, function () { |
277 | } | 287 | } |
278 | ); | 288 | ); |
279 | 289 | ||
280 | }; | 290 | }; |
281 | 291 | ||
282 | $scope.seleccionarVendedor = function () { | 292 | $scope.seleccionarVendedor = function () { |
283 | var parametrosModal = { | 293 | var parametrosModal = { |
284 | titulo: 'Búsqueda vendedores', | 294 | titulo: 'Búsqueda vendedores', |
285 | query: '/vendedor-playa', | 295 | query: '/vendedor-playa', |
286 | columnas: [ | 296 | columnas: [ |
287 | { | 297 | { |
288 | propiedad: 'CodVen', | 298 | propiedad: 'CodVen', |
289 | nombre: 'Código', | 299 | nombre: 'Código', |
290 | filtro: { | 300 | filtro: { |
291 | nombre: 'rellenarDigitos', | 301 | nombre: 'rellenarDigitos', |
292 | parametro: 3 | 302 | parametro: 3 |
293 | } | 303 | } |
294 | }, | 304 | }, |
295 | { | 305 | { |
296 | propiedad: 'NomVen', | 306 | propiedad: 'NomVen', |
297 | nombre: 'Nombre' | 307 | nombre: 'Nombre' |
298 | } | 308 | } |
299 | ], | 309 | ], |
300 | size: 'md' | 310 | size: 'md' |
301 | }; | 311 | }; |
302 | focaModalService.modal(parametrosModal).then( | 312 | focaModalService.modal(parametrosModal).then( |
303 | function (vendedor) { | 313 | function (vendedor) { |
304 | 314 | ||
305 | indicarPassword(vendedor) | 315 | indicarPassword(vendedor) |
306 | .then(function () { | 316 | .then(function () { |
307 | validarPlanillaVendedor(vendedor) | 317 | validarPlanillaVendedor(vendedor) |
308 | .then(function () { | 318 | .then(function () { |
309 | 319 | ||
310 | $filter('filter')($scope.botonera, { | 320 | $filter('filter')($scope.botonera, { |
311 | label: 'Vendedor' | 321 | label: 'Vendedor' |
312 | })[0].checked = true; | 322 | })[0].checked = true; |
313 | 323 | ||
314 | $scope.$broadcast('addCabecera', { | 324 | $scope.$broadcast('addCabecera', { |
315 | label: 'Vendedor:', | 325 | label: 'Vendedor:', |
316 | valor: $filter('rellenarDigitos')(vendedor.CodVen, 3) + | 326 | valor: $filter('rellenarDigitos')(vendedor.CodVen, 3) + |
317 | ' - ' + | 327 | ' - ' + |
318 | vendedor.NomVen | 328 | vendedor.NomVen |
319 | }); | 329 | }); |
320 | 330 | ||
321 | $scope.factura.vendedor = vendedor; | 331 | $scope.factura.vendedor = vendedor; |
322 | 332 | ||
323 | getProductosByPlanilla(vendedor.NplVen); | 333 | getProductosByPlanilla(vendedor.NplVen); |
324 | }) | 334 | }) |
325 | .catch($scope.seleccionarVendedor); | 335 | .catch($scope.seleccionarVendedor); |
326 | }) | 336 | }) |
327 | .catch(function (err) { | 337 | .catch(function (err) { |
328 | console.error(err); | 338 | console.error(err); |
329 | }); | 339 | }); |
330 | 340 | ||
331 | }, function () { } | 341 | }, function () { } |
332 | ); | 342 | ); |
333 | }; | 343 | }; |
334 | 344 | ||
335 | $scope.seleccionarMoneda = function () { | 345 | $scope.seleccionarMoneda = function () { |
336 | 346 | ||
337 | var parametrosModal = { | 347 | var parametrosModal = { |
338 | titulo: 'Búsqueda de monedas', | 348 | titulo: 'Búsqueda de monedas', |
339 | query: '/moneda', | 349 | query: '/moneda', |
340 | columnas: [ | 350 | columnas: [ |
341 | { | 351 | { |
342 | propiedad: 'DETALLE', | 352 | propiedad: 'DETALLE', |
343 | nombre: 'Nombre' | 353 | nombre: 'Nombre' |
344 | }, | 354 | }, |
345 | { | 355 | { |
346 | propiedad: 'SIMBOLO', | 356 | propiedad: 'SIMBOLO', |
347 | nombre: 'Símbolo' | 357 | nombre: 'Símbolo' |
348 | } | 358 | } |
349 | ], | 359 | ], |
350 | size: 'md' | 360 | size: 'md' |
351 | }; | 361 | }; |
352 | focaModalService.modal(parametrosModal).then( | 362 | focaModalService.modal(parametrosModal).then( |
353 | function (moneda) { | 363 | function (moneda) { |
354 | 364 | ||
355 | if (moneda.ID !== 1) { | 365 | if (moneda.ID !== 1) { |
356 | $scope.abrirModalCotizacion(moneda); | 366 | $scope.abrirModalCotizacion(moneda); |
357 | return; | 367 | return; |
358 | } | 368 | } |
359 | 369 | ||
360 | crearRemitoService.getCotizacionByIdMoneda(1) | 370 | crearRemitoService.getCotizacionByIdMoneda(1) |
361 | .then(function (res) { | 371 | .then(function (res) { |
362 | 372 | ||
363 | var cotizacionPArgentino = res.data[0].cotizaciones[0]; | 373 | var cotizacionPArgentino = res.data[0].cotizaciones[0]; |
364 | cotizacionPArgentino.moneda = moneda; | 374 | cotizacionPArgentino.moneda = moneda; |
365 | 375 | ||
366 | actualizarCabeceraMoneda(cotizacionPArgentino); | 376 | actualizarCabeceraMoneda(cotizacionPArgentino); |
367 | 377 | ||
368 | $scope.remito.cotizacion = cotizacionPArgentino; | 378 | $scope.remito.cotizacion = cotizacionPArgentino; |
369 | }); | 379 | }); |
370 | }, function () { | 380 | }, function () { |
371 | 381 | ||
372 | } | 382 | } |
373 | ); | 383 | ); |
374 | }; | 384 | }; |
375 | 385 | ||
376 | $scope.abrirModalCotizacion = function (moneda) { | 386 | $scope.abrirModalCotizacion = function (moneda) { |
377 | var modalInstance = $uibModal.open( | 387 | var modalInstance = $uibModal.open( |
378 | { | 388 | { |
379 | ariaLabelledBy: 'Busqueda de Cotización', | 389 | ariaLabelledBy: 'Busqueda de Cotización', |
380 | templateUrl: 'modal-cotizacion.html', | 390 | templateUrl: 'modal-cotizacion.html', |
381 | controller: 'focaModalCotizacionController', | 391 | controller: 'focaModalCotizacionController', |
382 | size: 'lg', | 392 | size: 'lg', |
383 | resolve: { idMoneda: function () { return moneda.ID; } } | 393 | resolve: { idMoneda: function () { return moneda.ID; } } |
384 | } | 394 | } |
385 | ); | 395 | ); |
386 | modalInstance.result.then( | 396 | modalInstance.result.then( |
387 | function (cotizacion) { | 397 | function (cotizacion) { |
388 | 398 | ||
389 | cotizacion.moneda = moneda; | 399 | cotizacion.moneda = moneda; |
390 | actualizarCabeceraMoneda(cotizacion); | 400 | actualizarCabeceraMoneda(cotizacion); |
391 | $scope.factura.cotizacion = cotizacion; | 401 | $scope.factura.cotizacion = cotizacion; |
392 | 402 | ||
393 | }, function () { | 403 | }, function () { |
394 | 404 | ||
395 | } | 405 | } |
396 | ); | 406 | ); |
397 | }; | 407 | }; |
398 | 408 | ||
399 | $scope.seleccionarObservaciones = function () { | 409 | $scope.seleccionarObservaciones = function () { |
400 | var observacion = { | 410 | var observacion = { |
401 | titulo: 'Ingrese Observaciones', | 411 | titulo: 'Ingrese Observaciones', |
402 | value: $scope.factura.observaciones, | 412 | value: $scope.factura.observaciones, |
403 | maxlength: 155, | 413 | maxlength: 155, |
404 | textarea: true | 414 | textarea: true |
405 | }; | 415 | }; |
406 | 416 | ||
407 | focaModalService | 417 | focaModalService |
408 | .prompt(observacion) | 418 | .prompt(observacion) |
409 | .then(function (observaciones) { | 419 | .then(function (observaciones) { |
410 | $scope.factura.observaciones = observaciones; | 420 | $scope.factura.observaciones = observaciones; |
411 | }); | 421 | }); |
412 | }; | 422 | }; |
413 | 423 | ||
414 | $scope.articulosFiltro = function () { | 424 | $scope.articulosFiltro = function () { |
415 | return $scope.factura.articulosFactura.filter(function (articulo) { | 425 | return $scope.factura.articulosFactura.filter(function (articulo) { |
416 | return !articulo.desactivado; | 426 | return !articulo.desactivado; |
417 | }); | 427 | }); |
418 | }; | 428 | }; |
419 | 429 | ||
420 | $scope.getTotal = function () { | 430 | $scope.getTotal = function () { |
421 | 431 | ||
422 | var total = 0; | 432 | var total = 0; |
423 | 433 | ||
424 | $scope.articulosFiltro().forEach(function (articulo) { | 434 | $scope.articulosFiltro().forEach(function (articulo) { |
425 | total += articulo.PUN * articulo.CAN; | 435 | total += articulo.PUN * articulo.CAN; |
426 | }); | 436 | }); |
427 | 437 | ||
428 | return parseFloat(total.toFixed(2)); | 438 | return parseFloat(total.toFixed(2)); |
429 | }; | 439 | }; |
430 | 440 | ||
431 | $scope.quitarDespacho = function (articulo, index) { | 441 | $scope.quitarDespacho = function (articulo, index) { |
432 | 442 | ||
433 | crearFacturaService | 443 | crearFacturaService |
434 | .setearDespachoDesocupado({ | 444 | .setearDespachoDesocupado({ |
435 | surtidor: $scope.factura.despachos[index].SUR, | 445 | surtidor: $scope.factura.despachos[index].SUR, |
436 | producto: $scope.factura.despachos[index].PRO, | 446 | producto: $scope.factura.despachos[index].PRO, |
437 | carga: $scope.factura.despachos[index].CAR, | 447 | carga: $scope.factura.despachos[index].CAR, |
438 | planilla: $scope.factura.despachos[index].PLA | 448 | planilla: $scope.factura.despachos[index].PLA |
439 | }) | 449 | }) |
440 | .then(function () { | 450 | .then(function () { |
441 | articulo.desactivado = true; | 451 | articulo.desactivado = true; |
442 | $scope.factura.despachos.splice(index, 1); | 452 | $scope.factura.despachos.splice(index, 1); |
443 | }) | 453 | }) |
444 | .catch(function () { | 454 | .catch(function () { |
445 | focaModalService.alert('Hubo un error al desasociar este despacho'); | 455 | focaModalService.alert('Hubo un error al desasociar este despacho'); |
446 | }); | 456 | }); |
447 | }; | 457 | }; |
448 | 458 | ||
449 | function getProductosByPlanilla(numeroPlanilla) { | 459 | function getProductosByPlanilla(numeroPlanilla) { |
450 | 460 | ||
451 | crearFacturaService.getProductosByPlanilla(numeroPlanilla).then(function (res) { | 461 | crearFacturaService.getProductosByPlanilla(numeroPlanilla).then(function (res) { |
452 | 462 | ||
453 | if (!res.data.length) { | 463 | if (!res.data.length) { |
454 | 464 | ||
455 | focaModalService.alert('No hay despachos disponibles por el momento'); | 465 | focaModalService.alert('No hay despachos disponibles por el momento'); |
456 | return; | 466 | return; |
457 | } | 467 | } |
458 | 468 | ||
459 | $scope.botoneraProductos.length = 0; | 469 | $scope.botoneraProductos.length = 0; |
460 | res.data.forEach(function (producto) { | 470 | res.data.forEach(function (producto) { |
461 | 471 | ||
462 | $scope.botoneraProductos.push({ | 472 | $scope.botoneraProductos.push({ |
463 | label: producto.DetArt, | 473 | label: producto.DetArt, |
464 | image: producto.nombreImagen, | 474 | image: producto.nombreImagen, |
465 | imageDefault: 'productoDefault.png' | 475 | imageDefault: 'productoDefault.png' |
466 | }); | 476 | }); |
467 | 477 | ||
468 | crearFuncionesProductos(producto); | 478 | crearFuncionesProductos(producto); |
469 | }); | 479 | }); |
470 | }); | 480 | }); |
471 | } | 481 | } |
472 | 482 | ||
473 | $scope.seleccionarBusquedaProductos = function () { | 483 | $scope.seleccionarBusquedaProductos = function () { |
474 | 484 | ||
475 | if (angular.equals({}, $scope.factura.vendedor)) { | 485 | if (angular.equals({}, $scope.factura.vendedor)) { |
476 | 486 | ||
477 | focaModalService.alert('Seleccione Vendedor'); | 487 | focaModalService.alert('Seleccione Vendedor'); |
478 | return false; | 488 | return false; |
479 | } | 489 | } |
480 | 490 | ||
481 | var modalInstance = $uibModal.open( | 491 | var modalInstance = $uibModal.open( |
482 | { | 492 | { |
483 | ariaLabelledBy: 'Busqueda de Productos', | 493 | ariaLabelledBy: 'Busqueda de Productos', |
484 | templateUrl: 'modal-busqueda-productos.html', | 494 | templateUrl: 'modal-busqueda-productos.html', |
485 | controller: 'modalBusquedaProductosCtrl', | 495 | controller: 'modalBusquedaProductosCtrl', |
486 | resolve: { | 496 | resolve: { |
487 | parametroProducto: { | 497 | parametroProducto: { |
488 | idLista: null, | 498 | idLista: null, |
489 | cotizacion: $scope.factura.cotizacion.VENDEDOR, | 499 | cotizacion: $scope.factura.cotizacion.VENDEDOR, |
490 | simbolo: $scope.factura.cotizacion.moneda.SIMBOLO, | 500 | simbolo: $scope.factura.cotizacion.moneda.SIMBOLO, |
491 | buscarTodos: true | 501 | buscarTodos: true |
492 | } | 502 | } |
493 | }, | 503 | }, |
494 | size: 'lg' | 504 | size: 'lg' |
495 | } | 505 | } |
496 | ); | 506 | ); |
497 | 507 | ||
498 | modalInstance.result | 508 | modalInstance.result |
499 | .then(function (producto) { | 509 | .then(function (producto) { |
500 | 510 | ||
501 | var articulo = { | 511 | var articulo = { |
502 | TIP: $scope.factura.cliente.tipoFactura, | 512 | TIP: $scope.factura.cliente.tipoFactura, |
503 | TCO: 'FT', | 513 | TCO: 'FT', |
504 | SUC: parseInt($scope.puntoVenta), | 514 | SUC: parseInt($scope.puntoVenta), |
505 | ORD: $scope.articulosFiltro().length + 1, | 515 | ORD: $scope.articulosFiltro().length + 1, |
506 | SEC: producto.sector, | 516 | SEC: producto.sector, |
507 | ART: producto.codigo, | 517 | ART: producto.codigo, |
508 | RUB: producto.CodRub, | 518 | RUB: producto.CodRub, |
509 | DES: producto.descripcionLarga, | 519 | DES: producto.descripcionLarga, |
510 | PUN: producto.precio, // TODO | 520 | PUN: producto.precio, // TODO |
511 | IVA: producto.IMPIVA, // TODO | 521 | IVA: producto.IMPIVA, // TODO |
512 | NET: 0, // TODO | 522 | NET: 0, // TODO |
513 | NEX: 0, // TODO | 523 | NEX: 0, // TODO |
514 | IMI: producto.ImpInt, // TODO | 524 | IMI: producto.ImpInt, // TODO |
515 | IMI2: producto.ImpInt2, // TODO | 525 | IMI2: producto.ImpInt2, // TODO |
516 | IMI3: producto.ImpInt3, // TODO | 526 | IMI3: producto.ImpInt3, // TODO |
517 | PUT: producto.PreNet, // TODO | 527 | PUT: producto.PreNet, // TODO |
518 | SUR: 0, | 528 | SUR: 0, |
519 | PLA: $scope.factura.vendedor.NplVen, | 529 | PLA: $scope.factura.vendedor.NplVen, |
520 | LUG: $scope.factura.vendedor.LugVen, | 530 | LUG: $scope.factura.vendedor.LugVen, |
521 | LEG: $scope.factura.vendedor.CodVen, | 531 | LEG: $scope.factura.vendedor.CodVen, |
522 | TUR: $scope.factura.vendedor.TurVen, | 532 | TUR: $scope.factura.vendedor.TurVen, |
523 | ORDEN_PRECOMPRA: '', | 533 | ORDEN_PRECOMPRA: '', |
524 | ESC: producto.tipoFactura === 'L' ? 1 : 0, | 534 | ESC: producto.tipoFactura === 'L' ? 1 : 0, |
525 | CMF: 0, | 535 | CMF: 0, |
526 | PTA: 0, | 536 | PTA: 0, |
527 | IVS: 0, | 537 | IVS: 0, |
528 | TIVA: 0, | 538 | TIVA: 0, |
529 | CON: 0, | 539 | CON: 0, |
530 | SINO: '', | 540 | SINO: '', |
531 | ORD_TRA: 0, | 541 | ORD_TRA: 0, |
532 | IMP_DESP: 0, | 542 | IMP_DESP: 0, |
533 | PCD: 0, | 543 | PCD: 0, |
534 | RTO: '', | 544 | RTO: '', |
535 | }; | 545 | }; |
536 | 546 | ||
537 | $scope.factura.articulosFactura.push(articulo); | 547 | $scope.factura.articulosFactura.push(articulo); |
538 | $scope.cambioEdit(articulo, 'cantidad'); | 548 | $scope.cambioEdit(articulo, 'cantidad'); |
539 | 549 | ||
540 | }) | 550 | }) |
541 | .catch(function (e) { console.error(e); }); | 551 | .catch(function (e) { console.error(e); }); |
542 | }; | 552 | }; |
543 | 553 | ||
544 | function crearFuncionesProductos(producto) { | 554 | function crearFuncionesProductos(producto) { |
545 | 555 | ||
546 | $scope[nombreFuncion(producto.DetArt)] = function () { | 556 | $scope[nombreFuncion(producto.DetArt)] = function () { |
547 | 557 | ||
548 | if (angular.equals($scope.factura.cliente, {})) { | 558 | if (angular.equals($scope.factura.cliente, {})) { |
549 | focaModalService.alert('Seleccione cliente'); | 559 | focaModalService.alert('Seleccione cliente'); |
550 | return; | 560 | return; |
551 | } | 561 | } |
552 | 562 | ||
553 | var modalInstance = $uibModal.open( | 563 | var modalInstance = $uibModal.open( |
554 | { | 564 | { |
555 | templateUrl: 'modal-combustibles.html', | 565 | templateUrl: 'modal-combustibles.html', |
556 | controller: 'focaModalCombustiblesController', | 566 | controller: 'focaModalCombustiblesController', |
557 | resolve: { | 567 | resolve: { |
558 | parametros: function () { | 568 | parametros: function () { |
559 | return { | 569 | return { |
560 | despachos: producto.despachos, | 570 | despachos: producto.despachos, |
561 | nombreProducto: producto.DetArt | 571 | nombreProducto: producto.DetArt |
562 | }; | 572 | }; |
563 | } | 573 | } |
564 | }, | 574 | }, |
565 | size: 'md' | 575 | size: 'md' |
566 | } | 576 | } |
567 | ); | 577 | ); |
568 | 578 | ||
569 | modalInstance.result.then(function (despacho) { | 579 | modalInstance.result.then(function (despacho) { |
570 | 580 | ||
571 | var articulo = { | 581 | var articulo = { |
572 | TIP: $scope.factura.cliente.tipoFactura, | 582 | TIP: $scope.factura.cliente.tipoFactura, |
573 | TCO: 'FT', | 583 | TCO: 'FT', |
574 | SUC: parseInt($scope.puntoVenta), | 584 | SUC: parseInt($scope.puntoVenta), |
575 | ORD: $scope.articulosFiltro().length + 1, | 585 | ORD: $scope.articulosFiltro().length + 1, |
576 | SEC: despacho.SEC, | 586 | SEC: despacho.SEC, |
577 | ART: despacho.PRO, | 587 | ART: despacho.PRO, |
578 | RUB: producto.CodRub, | 588 | RUB: producto.CodRub, |
579 | DES: producto.DetArt, | 589 | DES: producto.DetArt, |
580 | CAN: despacho.LTS, | 590 | CAN: despacho.LTS, |
581 | PUN: producto.PreVen, // TODO | 591 | PUN: producto.PreVen, // TODO |
582 | IVA: producto.IMPIVA, // TODO | 592 | IVA: producto.IMPIVA, // TODO |
583 | NET: 0, // TODO | 593 | NET: 0, // TODO |
584 | NEX: 0, // TODO | 594 | NEX: 0, // TODO |
585 | IMI: producto.ImpInt, // TODO | 595 | IMI: producto.ImpInt, // TODO |
586 | IMI2: producto.ImpInt2, // TODO | 596 | IMI2: producto.ImpInt2, // TODO |
587 | IMI3: producto.ImpInt3, // TODO | 597 | IMI3: producto.ImpInt3, // TODO |
588 | PUT: producto.PreNet, // TODO | 598 | PUT: producto.PreNet, // TODO |
589 | SUR: despacho.SUR, | 599 | SUR: despacho.SUR, |
590 | PLA: despacho.PLA, | 600 | PLA: despacho.PLA, |
591 | LUG: despacho.LUG, | 601 | LUG: despacho.LUG, |
592 | LEG: $scope.factura.vendedor.CodVen, | 602 | LEG: $scope.factura.vendedor.CodVen, |
593 | TUR: $scope.factura.vendedor.TurVen, | 603 | TUR: $scope.factura.vendedor.TurVen, |
594 | ORDEN_PRECOMPRA: '', | 604 | ORDEN_PRECOMPRA: '', |
595 | ESC: producto.tipoFactura === 'L' ? 1 : 0, | 605 | ESC: producto.tipoFactura === 'L' ? 1 : 0, |
596 | CMF: 0, | 606 | CMF: 0, |
597 | PTA: 0, | 607 | PTA: 0, |
598 | IVS: 0, | 608 | IVS: 0, |
599 | TIVA: 0, | 609 | TIVA: 0, |
600 | CON: 0, | 610 | CON: 0, |
601 | SINO: '', | 611 | SINO: '', |
602 | ORD_TRA: 0, | 612 | ORD_TRA: 0, |
603 | IMP_DESP: 0, | 613 | IMP_DESP: 0, |
604 | PCD: 0, | 614 | PCD: 0, |
605 | RTO: '', | 615 | RTO: '', |
606 | }; | 616 | }; |
607 | 617 | ||
608 | crearFacturaService.setearDespachoOcupado({ | 618 | crearFacturaService.setearDespachoOcupado({ |
609 | surtidor: despacho.SUR, | 619 | surtidor: despacho.SUR, |
610 | producto: despacho.PRO, | 620 | producto: despacho.PRO, |
611 | carga: despacho.CAR | 621 | carga: despacho.CAR |
612 | }) | 622 | }) |
613 | .then(function () { | 623 | .then(function () { |
614 | $scope.factura.articulosFactura.push(articulo); | 624 | $scope.factura.articulosFactura.push(articulo); |
615 | $scope.factura.despachos.push(despacho); | 625 | $scope.factura.despachos.push(despacho); |
616 | }) | 626 | }) |
617 | .catch(function (err) { | 627 | .catch(function (err) { |
618 | 628 | ||
619 | console.error(err); | 629 | console.error(err); |
620 | focaModalService.alert('El despacho esta en uso'); | 630 | focaModalService.alert('El despacho esta en uso'); |
621 | }); | 631 | }); |
622 | 632 | ||
623 | }) | 633 | }) |
624 | .catch(function (err) { | 634 | .catch(function (err) { |
625 | console.error(err); | 635 | console.error(err); |
626 | }); | 636 | }); |
627 | 637 | ||
628 | }; | 638 | }; |
629 | } | 639 | } |
630 | 640 | ||
631 | function nombreFuncion(string) { | 641 | function nombreFuncion(string) { |
632 | var texto = 'seleccionar'; | 642 | var texto = 'seleccionar'; |
633 | var arr = string.split(' '); | 643 | var arr = string.split(' '); |
634 | arr.forEach(function (palabra) { | 644 | arr.forEach(function (palabra) { |
635 | palabra = palabra.charAt(0).toUpperCase() + palabra.slice(1); | 645 | palabra = palabra.charAt(0).toUpperCase() + palabra.slice(1); |
636 | texto += palabra; | 646 | texto += palabra; |
637 | }); | 647 | }); |
638 | return texto; | 648 | return texto; |
639 | } | 649 | } |
640 | 650 | ||
641 | function indicarPassword(vendedor) { | 651 | function indicarPassword(vendedor) { |
642 | 652 | ||
643 | return new Promise(function (resolve, reject) { | 653 | return new Promise(function (resolve, reject) { |
644 | 654 | ||
645 | function openPrompt() { | 655 | function openPrompt() { |
646 | return focaModalService | 656 | return focaModalService |
647 | .prompt({ | 657 | .prompt({ |
648 | titulo: 'Indique Contraseña', | 658 | titulo: 'Indique Contraseña', |
649 | value: '' | 659 | value: '' |
650 | }) | 660 | }) |
651 | .then(function (contraseña) { | 661 | .then(function (contraseña) { |
652 | 662 | ||
653 | if (contraseña !== vendedor.ClaVen.trim()) { | 663 | if (contraseña !== vendedor.ClaVen.trim()) { |
654 | 664 | ||
655 | focaModalService.alert('Clave incorrecta').then(function () { | 665 | focaModalService.alert('Clave incorrecta').then(function () { |
656 | openPrompt(vendedor); | 666 | openPrompt(vendedor); |
657 | }); | 667 | }); |
658 | } else { | 668 | } else { |
659 | resolve(); | 669 | resolve(); |
660 | } | 670 | } |
661 | }) | 671 | }) |
662 | .catch(reject); | 672 | .catch(reject); |
663 | } | 673 | } |
664 | 674 | ||
665 | openPrompt(); | 675 | openPrompt(); |
666 | }); | 676 | }); |
667 | } | 677 | } |
668 | 678 | ||
669 | function validarPlanillaVendedor(vendedor) { | 679 | function validarPlanillaVendedor(vendedor) { |
670 | 680 | ||
671 | return new Promise(function (resolve, reject) { | 681 | return new Promise(function (resolve, reject) { |
672 | 682 | ||
673 | crearFacturaService | 683 | crearFacturaService |
674 | .validarPlanillaVendedor(vendedor.CodVen.toString().trim()) | 684 | .validarPlanillaVendedor(vendedor.CodVen.toString().trim()) |
675 | .then(function (res) { | 685 | .then(function (res) { |
676 | 686 | ||
677 | if (!res.data.length) { | 687 | if (!res.data.length) { |
678 | 688 | ||
679 | focaModalService | 689 | focaModalService |
680 | .alert('No se encontró planilla abierta para el vendedor') | 690 | .alert('No se encontró planilla abierta para el vendedor') |
681 | .then(reject); | 691 | .then(reject); |
682 | 692 | ||
683 | } else { | 693 | } else { |
684 | resolve(); | 694 | resolve(); |
685 | } | 695 | } |
686 | 696 | ||
687 | }) | 697 | }) |
688 | .catch(function (err) { | 698 | .catch(function (err) { |
689 | console.log(err) | 699 | console.log(err) |
690 | reject(); | 700 | reject(); |
691 | }); | 701 | }); |
692 | }); | 702 | }); |
693 | } | 703 | } |
694 | 704 | ||
695 | function rellenar(relleno, longitud) { | 705 | function rellenar(relleno, longitud) { |
696 | relleno = '' + relleno; | 706 | relleno = '' + relleno; |
697 | while (relleno.length < longitud) { | 707 | while (relleno.length < longitud) { |
698 | relleno = '0' + relleno; | 708 | relleno = '0' + relleno; |
699 | } | 709 | } |
700 | return relleno; | 710 | return relleno; |
701 | } | 711 | } |
702 | 712 | ||
703 | $scope.salir = function () { | 713 | $scope.salir = function () { |
704 | var confirmacion = false; | 714 | var confirmacion = false; |
705 | 715 | ||
706 | if (!angular.equals($scope.factura, $scope.inicial)) { | 716 | if (!angular.equals($scope.factura, $scope.inicial)) { |
707 | confirmacion = true; | 717 | confirmacion = true; |
708 | } | 718 | } |
709 | 719 | ||
710 | if (confirmacion) { | 720 | if (confirmacion) { |
711 | focaModalService.confirm( | 721 | focaModalService.confirm( |
712 | '¿Está seguro de que desea salir? Se perderán todos los datos cargados.' | 722 | '¿Está seguro de que desea salir? Se perderán todos los datos cargados.' |
713 | ).then(function (data) { | 723 | ).then(function (data) { |
714 | if (data) { | 724 | if (data) { |
715 | $location.path('/'); | 725 | $location.path('/'); |
716 | } | 726 | } |
717 | }); | 727 | }); |
718 | } else { | 728 | } else { |
719 | $location.path('/'); | 729 | $location.path('/'); |
720 | } | 730 | } |
721 | } | 731 | } |
722 | 732 | ||
723 | function setearFactura(factura) { | 733 | function setearFactura(factura) { |
724 | 734 | ||
725 | $scope.$broadcast('cleanCabecera'); | 735 | $scope.$broadcast('cleanCabecera'); |
726 | 736 | ||
727 | $scope.cabeceras = []; | 737 | $scope.cabeceras = []; |
728 | 738 | ||
729 | if (factura.cotizacion && factura.cotizacion.moneda.CODIGO_AFIP !== 'PES') { | 739 | if (factura.cotizacion && factura.cotizacion.moneda.CODIGO_AFIP !== 'PES') { |
730 | $scope.cabeceras.push({ | 740 | $scope.cabeceras.push({ |
731 | label: 'Moneda:', | 741 | label: 'Moneda:', |
732 | valor: factura.cotizacion.moneda.DETALLE | 742 | valor: factura.cotizacion.moneda.DETALLE |
733 | }); | 743 | }); |
734 | $scope.cabeceras.push({ | 744 | $scope.cabeceras.push({ |
735 | label: 'Fecha cotizacion:', | 745 | label: 'Fecha cotizacion:', |
736 | valor: $filter('date')(factura.cotizacion.FECHA, | 746 | valor: $filter('date')(factura.cotizacion.FECHA, |
737 | 'dd/MM/yyyy') | 747 | 'dd/MM/yyyy') |
738 | }); | 748 | }); |
739 | $scope.cabeceras.push({ | 749 | $scope.cabeceras.push({ |
740 | label: 'Cotizacion:', | 750 | label: 'Cotizacion:', |
741 | valor: $filter('number')(factura.cotizacion.VENDEDOR, | 751 | valor: $filter('number')(factura.cotizacion.VENDEDOR, |
742 | '2') | 752 | '2') |
743 | }); | 753 | }); |
744 | } | 754 | } |
745 | 755 | ||
746 | if (factura.cotizacion && factura.cotizacion.moneda) { | 756 | if (factura.cotizacion && factura.cotizacion.moneda) { |
747 | // $filter('filter')($scope.botonera, { label: 'Moneda' })[0].checked = true; | 757 | // $filter('filter')($scope.botonera, { label: 'Moneda' })[0].checked = true; |
748 | } | 758 | } |
749 | 759 | ||
750 | if (factura.cliente && factura.cliente.cod) { | 760 | if (factura.cliente && factura.cliente.cod) { |
751 | $scope.cabeceras.push({ | 761 | $scope.cabeceras.push({ |
752 | label: 'Cliente:', | 762 | label: 'Cliente:', |
753 | valor: $filter('rellenarDigitos')(factura.cliente.cod, 3) + ' - ' + | 763 | valor: $filter('rellenarDigitos')(factura.cliente.cod, 3) + ' - ' + |
754 | factura.cliente.nom | 764 | factura.cliente.nom |
755 | }); | 765 | }); |
756 | 766 | ||
757 | $filter('filter')($scope.botonera, { label: 'Cliente' })[0].checked = true; | 767 | $filter('filter')($scope.botonera, { label: 'Cliente' })[0].checked = true; |
758 | } | 768 | } |
759 | 769 | ||
760 | $scope.puntoVenta = rellenar(factura.sucursal, 4); | 770 | $scope.puntoVenta = rellenar(factura.sucursal, 4); |
761 | $scope.comprobante = rellenar(factura.numerofactura, 8); | 771 | $scope.comprobante = rellenar(factura.numerofactura, 8); |
762 | $scope.factura = factura; | 772 | $scope.factura = factura; |
763 | 773 | ||
764 | addArrayCabecera($scope.cabeceras); | 774 | addArrayCabecera($scope.cabeceras); |
765 | } | 775 | } |
766 | 776 | ||
767 | function getLSFactura() { | 777 | function getLSFactura() { |
768 | var factura = JSON.parse($localStorage.factura || null); | 778 | var factura = JSON.parse($localStorage.factura || null); |
769 | if (factura) { | 779 | if (factura) { |
770 | setearFactura(factura); | 780 | setearFactura(factura); |
771 | delete $localStorage.factura; | 781 | delete $localStorage.factura; |
772 | } | 782 | } |
773 | } | 783 | } |
774 | 784 | ||
775 | function addArrayCabecera(array) { | 785 | function addArrayCabecera(array) { |
776 | for (var i = 0; i < array.length; i++) { | 786 | for (var i = 0; i < array.length; i++) { |
777 | $scope.$broadcast('addCabecera', { | 787 | $scope.$broadcast('addCabecera', { |
778 | label: array[i].label, | 788 | label: array[i].label, |
779 | valor: array[i].valor | 789 | valor: array[i].valor |
780 | }); | 790 | }); |
781 | } | 791 | } |
782 | } | 792 | } |
783 | 793 | ||
784 | $scope.cambioEdit = function (articulo, propiedad) { | 794 | $scope.cambioEdit = function (articulo, propiedad) { |
785 | if (propiedad === 'cantidad' && articulo.SUR !== 0) { | 795 | if (propiedad === 'cantidad' && articulo.SUR !== 0) { |
786 | articulo.editCantidad = true; | 796 | articulo.editCantidad = true; |
787 | } | 797 | } |
788 | }; | 798 | }; |
789 | 799 | ||
790 | $scope.editarArticulo = function (key, articulo, tmpCantidad) { | 800 | $scope.editarArticulo = function (key, articulo, tmpCantidad) { |
791 | if (key === 13) { | 801 | if (key === 13) { |
792 | if (!articulo.cantidad && tmpCantidad.length === 0) { | 802 | if (!articulo.cantidad && tmpCantidad.length === 0) { |
793 | focaModalService.alert('Los valores deben ser al menos 1'); | 803 | focaModalService.alert('Los valores deben ser al menos 1'); |
794 | return; | 804 | return; |
795 | } else if (tmpCantidad === '0') { | 805 | } else if (tmpCantidad === '0') { |
796 | focaModalService.alert('Esta ingresando un producto con valor 0'); | 806 | focaModalService.alert('Esta ingresando un producto con valor 0'); |
797 | return; | 807 | return; |
798 | } else if (parseInt(tmpCantidad) < 0) { | 808 | } else if (parseInt(tmpCantidad) < 0) { |
799 | focaModalService.alert('Los valores no pueden ser negativos'); | 809 | focaModalService.alert('Los valores no pueden ser negativos'); |
800 | return; | 810 | return; |
801 | } | 811 | } |
802 | articulo.CAN = parseInt(tmpCantidad); | 812 | articulo.CAN = parseInt(tmpCantidad); |
803 | $scope.getTotal(); | 813 | $scope.getTotal(); |
804 | articulo.editCantidad = false; | 814 | articulo.editCantidad = false; |
805 | } | 815 | } |
806 | }; | 816 | }; |
807 | 817 | ||
808 | $scope.cancelarEditar = function (articulo) { | 818 | $scope.cancelarEditar = function (articulo) { |
809 | $scope.tmpCantidad = articulo.CAN; | 819 | $scope.tmpCantidad = articulo.CAN; |
810 | articulo.editCantidad = false; | 820 | articulo.editCantidad = false; |
811 | }; | 821 | }; |
812 | 822 | ||
813 | function actualizarCabeceraMoneda(cotizacion) { | 823 | function actualizarCabeceraMoneda(cotizacion) { |
814 | 824 | ||
815 | $scope.factura.articulosFactura.forEach(function (art) { | 825 | $scope.factura.articulosFactura.forEach(function (art) { |
816 | art.PUN = (art.PUN * $scope.factura.cotizacion.VENDEDOR).toFixed(4); | 826 | art.PUN = (art.PUN * $scope.factura.cotizacion.VENDEDOR).toFixed(4); |
817 | art.PUN = (art.PUN / cotizacion.VENDEDOR).toFixed(4); | 827 | art.PUN = (art.PUN / cotizacion.VENDEDOR).toFixed(4); |
818 | }); | 828 | }); |
819 | 829 | ||
820 | if (cotizacion.moneda.DETALLE === 'PESOS ARGENTINOS') { | 830 | if (cotizacion.moneda.DETALLE === 'PESOS ARGENTINOS') { |
821 | $scope.$broadcast('removeCabecera', 'Moneda:'); | 831 | $scope.$broadcast('removeCabecera', 'Moneda:'); |
822 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); | 832 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); |
823 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); | 833 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); |
824 | } else { | 834 | } else { |
825 | $scope.$broadcast('addCabecera', { | 835 | $scope.$broadcast('addCabecera', { |
826 | label: 'Moneda:', | 836 | label: 'Moneda:', |
827 | valor: cotizacion.moneda.DETALLE | 837 | valor: cotizacion.moneda.DETALLE |
828 | }); | 838 | }); |
829 | $scope.$broadcast('addCabecera', { | 839 | $scope.$broadcast('addCabecera', { |
830 | label: 'Fecha cotizacion:', | 840 | label: 'Fecha cotizacion:', |
831 | valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') | 841 | valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') |
832 | }); | 842 | }); |
833 | $scope.$broadcast('addCabecera', { | 843 | $scope.$broadcast('addCabecera', { |
834 | label: 'Cotizacion:', | 844 | label: 'Cotizacion:', |
835 | valor: $filter('number')(cotizacion.VENDEDOR, '2') | 845 | valor: $filter('number')(cotizacion.VENDEDOR, '2') |
836 | }); | 846 | }); |
837 | } | 847 | } |
838 | } | 848 | } |
839 | 849 | ||
840 | function validarGuardar() { | 850 | function validarGuardar() { |
841 | 851 | ||
842 | if (angular.equals({}, $scope.factura.vendedor)) { | 852 | if (angular.equals({}, $scope.factura.vendedor)) { |
843 | 853 | ||
844 | focaModalService.alert('Seleccione Vendedor'); | 854 | focaModalService.alert('Seleccione Vendedor'); |
845 | return false; | 855 | return false; |
846 | } else if (angular.equals({}, $scope.factura.cliente)) { | 856 | } else if (angular.equals({}, $scope.factura.cliente)) { |
847 | 857 | ||
848 | focaModalService.alert('Seleccione Cliente'); | 858 | focaModalService.alert('Seleccione Cliente'); |
849 | return false; | 859 | return false; |
850 | } else if (!$scope.articulosFiltro().length) { | 860 | } else if (!$scope.articulosFiltro().length) { |
851 | 861 | ||
852 | focaModalService.alert('Seleccione al menos un Articulo'); | 862 | focaModalService.alert('Seleccione al menos un Articulo'); |
853 | return false; | 863 | return false; |
854 | } | 864 | } |
855 | 865 | ||
856 | return true; | 866 | return true; |
857 | } | 867 | } |
858 | } | 868 | } |
859 | ]); | 869 | ]); |
860 | 870 |
src/views/modal-estado-cuenta.html
1 | <div class="modal-header py-1"> | 1 | <div class="modal-header py-1"> |
2 | <div class="row w-100"> | 2 | <div class="row w-100"> |
3 | <div class="col-lg-6"> | 3 | <div class="col-lg-6"> |
4 | <h5 class="modal-title text-center my-1">Estado cuenta corriente</h5> | 4 | <h5 class="modal-title text-center my-1">Estado cuenta corriente</h5> |
5 | </div> | 5 | </div> |
6 | </div> | 6 | </div> |
7 | </div> | 7 | </div> |
8 | <div class="modal-body" id="modal-body"> | 8 | <div class="modal-body" id="modal-body"> |
9 | <div class="row m-3"> | 9 | <div class="row m-3"> |
10 | <div class="col"> | 10 | <div class="col"> |
11 | <div class="row mb-2"> | 11 | <div class="row mb-2"> |
12 | <div class="col text-center"> | 12 | <div class="col text-center"> |
13 | <p class="m-0">Autorizado</p> | 13 | <p class="m-0">Autorizado</p> |
14 | <p class="h5 m-0" ng-bind="estadoCuenta.autorizado | currency"></p> | 14 | <p class="h5 m-0" ng-bind="estadoCuenta.autorizado | currency"></p> |
15 | </div> | 15 | </div> |
16 | </div> | 16 | </div> |
17 | <div class="row border-top mb-2"> | 17 | <div class="row border-top mb-2"> |
18 | <div class="col text-center"> | 18 | <div class="col text-center"> |
19 | <p class="m-0">Extracciones</p> | 19 | <p class="m-0">Extracciones</p> |
20 | <p class="h5 m-0" ng-bind="estadoCuenta.extracciones | currency"></p> | 20 | <p class="h5 m-0" ng-bind="estadoCuenta.extracciones | currency"></p> |
21 | </div> | 21 | </div> |
22 | </div> | 22 | </div> |
23 | <div class="row border-top mb-2"> | 23 | <div class="row border-top mb-2"> |
24 | <div class="col text-center"> | 24 | <div class="col text-center"> |
25 | <p class="m-0">Saldo</p> | 25 | <p class="m-0">Saldo</p> |
26 | <p class="h5 m-0" ng-bind="estadoCuenta.saldo | currency"></p> | 26 | <p class="h5 m-0" ng-bind="estadoCuenta.saldo | currency"></p> |
27 | </div> | 27 | </div> |
28 | </div> | 28 | </div> |
29 | <div class="row border-top"> | 29 | <div class="row border-top"> |
30 | <div class="col text-center"> | 30 | <div class="col text-center"> |
31 | <p class="m-0">Situacion</p> | 31 | <p class="m-0">Situacion</p> |
32 | <h4> | 32 | <h4> |
33 | <p | 33 | <p |
34 | ng-show="estadoCuenta.situacion" | 34 | ng-show="estadoCuenta.situacion" |
35 | class="badge badge-success m-0 px-3">Permitido | 35 | class="badge badge-success m-0 px-3">Permitido |
36 | </p> | 36 | </p> |
37 | <p | 37 | <p |
38 | ng-show="!estadoCuenta.situacion" | 38 | ng-show="!estadoCuenta.situacion" |
39 | class="badge badge-danger m-0 px-3">No permitido | 39 | class="badge badge-danger m-0 px-3">No permitido |
40 | </p> | 40 | </p> |
41 | </h4> | 41 | </h4> |
42 | </div> | 42 | </div> |
43 | </div> | 43 | </div> |
44 | <div class="row border-top mb-2"> | 44 | <div class="row border-top mb-2"> |
45 | <div class="col text-center"> | 45 | <div class="col text-center"> |
46 | <p class="m-0">Facturas Vencidas</p> | 46 | <p class="m-0">Facturas Vencidas</p> |
47 | <p class="h5 m-0" ng-bind="estadoCuenta.facturasVencidas | currency"></p> | 47 | <p class="h5 m-0" ng-bind="estadoCuenta.facturasVencidas | currency"></p> |
48 | </div> | 48 | </div> |
49 | </div> | 49 | </div> |
50 | </div> | 50 | </div> |
51 | </div> | 51 | </div> |
52 | <div class="row h-25 align-items-center mx-0 botonera-secundaria"> | 52 | <div class="row h-25 align-items-center mx-0 botonera-secundaria"> |
53 | <div class="col-6 col-sm-4 offset-sm-2"> | 53 | <div class="col-6 col-sm-4 offset-sm-2"> |
54 | <button | 54 | <button |
55 | type="button" | 55 | type="button" |
56 | class="btn btn-sm btn-block btn-tarjeta rounded border p-1" | 56 | class="btn btn-sm btn-block btn-tarjeta rounded border p-1" |
57 | ng-disabled="!estadoCuenta.situacion" | 57 | ng-disabled="!estadoCuenta.situacion" |
58 | ng-click="elegirTipoDePago('Contado')" | 58 | ng-click="elegirTipoDePago({tipo: 'Contado', formaDePago: 1})" |
59 | > | 59 | > |
60 | <img ng-src="./img/contado.png" alt=""> | 60 | <img ng-src="./img/contado.png" alt=""> |
61 | <p class="m-0">Contado</p> | 61 | <p class="m-0">Contado</p> |
62 | </button> | 62 | </button> |
63 | </div> | 63 | </div> |
64 | <div class="col-6 col-sm-4"> | 64 | <div class="col-6 col-sm-4"> |
65 | <button | 65 | <button |
66 | type="button" | 66 | type="button" |
67 | class="btn btn-sm btn-block btn-tarjeta rounded border p-1" | 67 | class="btn btn-sm btn-block btn-tarjeta rounded border p-1" |
68 | ng-disabled="!estadoCuenta.situacion" | 68 | ng-disabled="!estadoCuenta.situacion" |
69 | foca-focus="true" | 69 | foca-focus="true" |
70 | ng-click="elegirTipoDePago('Cuenta Corriente')" | 70 | ng-click="elegirTipoDePago({tipo: 'Cuenta Corriente', formaDePago: 2})" |
71 | > | 71 | > |
72 | <img ng-src="./img/cuentaCorriente.png" alt=""> | 72 | <img ng-src="./img/cuentaCorriente.png" alt=""> |
73 | <p class="m-0">Cta. Corriente</p> | 73 | <p class="m-0">Cta. Corriente</p> |
74 | </button> | 74 | </button> |
75 | </div> | 75 | </div> |
76 | </div> | 76 | </div> |
77 | </div> | 77 | </div> |
78 | <div class="modal-footer py-2"> | 78 | <div class="modal-footer py-2"> |
79 | <button class="btn btn-sm btn-secondary" type="button" ng-click="cancel()">Cancelar</button> | 79 | <button class="btn btn-sm btn-secondary" type="button" ng-click="cancel()">Cancelar</button> |
80 | </div> | 80 | </div> |
81 | 81 |