UNPKG

cotizador

Version:

This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 13.0.0.

238 lines (231 loc) 15.2 kB
import * as i0 from '@angular/core'; import { Injectable, EventEmitter, Component, Input, Output, NgModule } from '@angular/core'; import * as i1 from '@angular/platform-browser'; import * as i2 from '@ionic/angular'; import { IonicModule } from '@ionic/angular'; import * as i3 from '@angular/common'; import { CommonModule } from '@angular/common'; import * as i4 from '@angular/forms'; import { ReactiveFormsModule, FormsModule } from '@angular/forms'; class CotizadorService { constructor() { } } CotizadorService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: CotizadorService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); CotizadorService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: CotizadorService, providedIn: 'root' }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: CotizadorService, decorators: [{ type: Injectable, args: [{ providedIn: 'root' }] }], ctorParameters: function () { return []; } }); class CotizadorComponent { constructor(sanitizer) { this.sanitizer = sanitizer; this.submitCredit = new EventEmitter(); this.minAmount = 0; this.maxAmount = 0; this.increment = 0; this.incrementFrecuncy = 0; this.insuranceCost = 0; this.insuranceToPay = 0; this.maxFrecuency = 0; this.minFrecuency = 0; this.frecuencySelect = ''; this.inputFrecuency = false; this.inner = false; this.frecuencyText = ''; this.title = ''; this.subtitle = ''; this.content = ''; this.amountToPay = 0; this.paymentsText = ''; this.paymentsTextComplement = ''; this.anualTax = 0; this.factor = 0; this.Iva = 0; this.inputAmountText = ''; this.inputPaymentsText = ''; } ngOnInit() { this.paymentsTextComplement = ''; this.incrementFrecuncy = 1; this.title = this.jsonCreditQuoteDesign.header.title; this.subtitle = this.jsonCreditQuoteDesign.header.subtitle; this.content = this.jsonCreditQuoteDesign.contentComponent.contentComponentInner; this.safeContentHeader = this.sanitizer.bypassSecurityTrustHtml(this.subtitle); this.safeContentCard = this.sanitizer.bypassSecurityTrustHtml(this.content); this.minAmount = this.jsonCreditQuoteDesign.contentComponent.minAmount; this.maxAmount = this.jsonCreditQuoteDesign.contentComponent.maxAmount; this.increment = this.jsonCreditQuoteDesign.contentComponent.increment; this.frecuency = this.jsonCreditQuoteDesign.contentComponent.frecuency.options; this.inputAmountText = this.jsonCreditQuoteDesign.contentComponent.inputAmountText; this.inputPaymentsText = this.jsonCreditQuoteDesign.contentComponent.inputPaymentsText; this.setVariable(); this.selectfrecuency(this.frecuency[0]); } paymentCalc(select) { this.inner = false; if (select == 'frecuency') { this.paymentsText = this.payments + ' ' + this.paymentsTextComplement; this.insuranceToPay = this.insuranceCost * this.payments; setTimeout(() => { this.inner = this.amountSelect > 0 ? true : false; }, 200); } else if (this.payments > 0) { this.insuranceToPay = this.insuranceCost * this.payments; setTimeout(() => { this.inner = true; }, 200); } if (this.frecuencySelect == 'Mensual') { this.amountToPay = ((this.amountSelect + this.insuranceToPay) * ((this.anualTax / 100) / 12)) / (1 - (Math.pow((1 + ((this.anualTax / 100) / 12)), (-this.payments)))); } else { this.amountToPay = ((((this.amountSelect + this.insuranceToPay) * (this.payments * this.factor) * this.anualTax)) + (this.amountSelect + this.insuranceToPay)) / this.payments; } this.setVariable(); let arraySubmit = { amountSelect: this.amountSelect, payments: this.payments, insuranceCost: this.insuranceCost, frecuency: this.frecuencySelect, amountToPay: this.amountToPay, amountToPayTotal: (this.amountToPay * this.payments), insuranceToPay: this.insuranceToPay, frecuencyText: this.frecuencyText }; this.submitCredit.emit(arraySubmit); } selectfrecuency(frecuency) { this.payments = 0; this.paymentsText = ''; this.inner = false; for (let i of this.frecuency) { i.selected = false; } this.frecuencySelect = frecuency.id; frecuency.selected = true; this.inputFrecuency = true; this.minFrecuency = frecuency.min; this.maxFrecuency = frecuency.max; this.frecuencyText = frecuency.text; this.paymentsTextComplement = frecuency.text2; this.insuranceCost = frecuency.insuranceCost; this.anualTax = frecuency.anualTax; this.factor = frecuency.factor; this.Iva = frecuency.iva; } setVariable() { setTimeout(() => { let contentHTML = document.querySelectorAll("span"); if (contentHTML == null) { this.setVariable(); } else { contentHTML.forEach(element => { switch (element.textContent) { case '{{maxAmount}}': { element.innerHTML = this.maxAmount.toLocaleString('en-US', { style: 'currency', currency: 'USD', }); break; } case '{{minAmount}}': { element.innerHTML = this.minAmount.toLocaleString('en-US', { style: 'currency', currency: 'USD', }); break; } case '{{amountSelect}}': { element.innerHTML = this.amountSelect.toLocaleString('en-US', { style: 'currency', currency: 'USD', }); break; } case '{{paymentsSelect}}': { element.innerHTML = this.payments.toString(); break; } case '{{paymentsText}}': { element.innerHTML = this.paymentsText; break; } case '{{frecuencyText}}': { element.innerHTML = this.frecuencyText; break; } case '{{amountToPay}}': { element.innerHTML = this.amountToPay.toLocaleString('en-US', { style: 'currency', currency: 'USD', }); break; } case '{{insuranceCost}}': { element.innerHTML = this.insuranceToPay.toLocaleString('en-US', { style: 'currency', currency: 'USD', }); break; } } }); } }, 200); } back() { console.log(''); } } CotizadorComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: CotizadorComponent, deps: [{ token: i1.DomSanitizer }], target: i0.ɵɵFactoryTarget.Component }); CotizadorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.3", type: CotizadorComponent, selector: "tks-cotizador", inputs: { jsonCreditQuoteDesign: "jsonCreditQuoteDesign" }, outputs: { submitCredit: "submitCredit" }, ngImport: i0, template: "<div class=\"creditQuote\">\n <h1>\n <ion-icon style=\"color:#493176; margin-left: -50px; cursor: pointer;\" name=\"arrow-back-outline\" (click)=\"back()\"></ion-icon>\n {{title}}\n </h1>\n <div class=\"inner\" [innerHTML]=\"subtitle\"></div>\n <h3 class=\"amountSelect\">{{amountSelect | currency}}</h3>\n <div style=\"text-align: -webkit-center;\">\n <ion-grid class=\"tabs\">\n <ion-row>\n <ion-col *ngFor=\"let item of frecuency\">\n <ion-chip (click)=\"selectfrecuency(item)\" [ngClass]=\"item.selected ? 'active' : 'nonActive' \">\n <ion-label>{{item.id}}</ion-label>\n </ion-chip>\n </ion-col>\n </ion-row>\n </ion-grid>\n <h4 class=\"labelsInputs\">{{inputAmountText}} <span>{{amountSelect | currency}}</span> </h4>\n <div class=\"inputRangeAmount\">\n <input class=\"range\" type=\"range\" min=\"{{minAmount}}\" max=\"{{maxAmount}}\" value=\"0\" step=\"{{increment}}\"\n [(ngModel)]=\"amountSelect\" (input)=\"paymentCalc('amout')\">\n </div>\n <h4 class=\"labelsInputs\">{{inputPaymentsText}} <span>{{paymentsText}}</span></h4>\n <div class=\"inputRangeFrecuency\" >\n <input class=\"range\" type=\"range\" min=\"{{minFrecuency}}\" max=\"{{maxFrecuency}}\" value=\"0\" step=\"{{incrementFrecuncy}}\"\n [(ngModel)]=\"payments\" (input)=\"paymentCalc('frecuency')\">\n </div>\n </div>\n <div class=\"inner2\" [innerHTML]=\"content\" *ngIf=\"inner\"></div>\n</div>\n", styles: [""], components: [{ type: i2.IonIcon, selector: "ion-icon", inputs: ["color", "flipRtl", "icon", "ios", "lazy", "md", "mode", "name", "sanitize", "size", "src"] }, { type: i2.IonGrid, selector: "ion-grid", inputs: ["fixed"] }, { type: i2.IonRow, selector: "ion-row" }, { type: i2.IonCol, selector: "ion-col", inputs: ["offset", "offsetLg", "offsetMd", "offsetSm", "offsetXl", "offsetXs", "pull", "pullLg", "pullMd", "pullSm", "pullXl", "pullXs", "push", "pushLg", "pushMd", "pushSm", "pushXl", "pushXs", "size", "sizeLg", "sizeMd", "sizeSm", "sizeXl", "sizeXs"] }, { type: i2.IonChip, selector: "ion-chip", inputs: ["color", "disabled", "mode", "outline"] }, { type: i2.IonLabel, selector: "ion-label", inputs: ["color", "mode", "position"] }], directives: [{ type: i3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i3.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i4.RangeValueAccessor, selector: "input[type=range][formControlName],input[type=range][formControl],input[type=range][ngModel]" }, { type: i4.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i4.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i4.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], pipes: { "currency": i3.CurrencyPipe } }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: CotizadorComponent, decorators: [{ type: Component, args: [{ selector: 'tks-cotizador', template: "<div class=\"creditQuote\">\n <h1>\n <ion-icon style=\"color:#493176; margin-left: -50px; cursor: pointer;\" name=\"arrow-back-outline\" (click)=\"back()\"></ion-icon>\n {{title}}\n </h1>\n <div class=\"inner\" [innerHTML]=\"subtitle\"></div>\n <h3 class=\"amountSelect\">{{amountSelect | currency}}</h3>\n <div style=\"text-align: -webkit-center;\">\n <ion-grid class=\"tabs\">\n <ion-row>\n <ion-col *ngFor=\"let item of frecuency\">\n <ion-chip (click)=\"selectfrecuency(item)\" [ngClass]=\"item.selected ? 'active' : 'nonActive' \">\n <ion-label>{{item.id}}</ion-label>\n </ion-chip>\n </ion-col>\n </ion-row>\n </ion-grid>\n <h4 class=\"labelsInputs\">{{inputAmountText}} <span>{{amountSelect | currency}}</span> </h4>\n <div class=\"inputRangeAmount\">\n <input class=\"range\" type=\"range\" min=\"{{minAmount}}\" max=\"{{maxAmount}}\" value=\"0\" step=\"{{increment}}\"\n [(ngModel)]=\"amountSelect\" (input)=\"paymentCalc('amout')\">\n </div>\n <h4 class=\"labelsInputs\">{{inputPaymentsText}} <span>{{paymentsText}}</span></h4>\n <div class=\"inputRangeFrecuency\" >\n <input class=\"range\" type=\"range\" min=\"{{minFrecuency}}\" max=\"{{maxFrecuency}}\" value=\"0\" step=\"{{incrementFrecuncy}}\"\n [(ngModel)]=\"payments\" (input)=\"paymentCalc('frecuency')\">\n </div>\n </div>\n <div class=\"inner2\" [innerHTML]=\"content\" *ngIf=\"inner\"></div>\n</div>\n", styles: [""] }] }], ctorParameters: function () { return [{ type: i1.DomSanitizer }]; }, propDecorators: { jsonCreditQuoteDesign: [{ type: Input }], submitCredit: [{ type: Output }] } }); class CotizadorModule { } CotizadorModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: CotizadorModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); CotizadorModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: CotizadorModule, declarations: [CotizadorComponent], imports: [CommonModule, IonicModule, ReactiveFormsModule, FormsModule], exports: [CotizadorComponent] }); CotizadorModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: CotizadorModule, imports: [[ CommonModule, IonicModule, ReactiveFormsModule, FormsModule, ]] }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: CotizadorModule, decorators: [{ type: NgModule, args: [{ declarations: [ CotizadorComponent ], imports: [ CommonModule, IonicModule, ReactiveFormsModule, FormsModule, ], exports: [ CotizadorComponent ] }] }] }); /* * Public API Surface of cotizador */ /** * Generated bundle index. Do not edit. */ export { CotizadorComponent, CotizadorModule, CotizadorService }; //# sourceMappingURL=cotizador.mjs.map