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