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