|
|
@@ -5,7 +5,7 @@ import {
|
|
|
ViewChild,
|
|
|
ComponentFactoryResolver
|
|
|
} from "@angular/core";
|
|
|
-import { Router } from "@angular/router";
|
|
|
+import { Router, ActivatedRoute } from "@angular/router";
|
|
|
import { InvestmentProposalForm } from "@app/models/investment-proposal-form";
|
|
|
import { FormInvestmentProposalService } from "@app/services/form-investment-proposal.service";
|
|
|
import { Instrument } from "@app/models/instrument";
|
|
|
@@ -14,6 +14,8 @@ import { InstrumentDirective } from "../instrument/instrument.directive";
|
|
|
import { InstrumentComponent } from "../instrument/instrument.component";
|
|
|
import { InstrumentsService } from "@app/services/instruments.service";
|
|
|
import Swal from "sweetalert2";
|
|
|
+import { CatalogsService } from "@app/services/catalogs.service";
|
|
|
+import { InvestmentsService } from "@app/services/investments.service";
|
|
|
|
|
|
@Component({
|
|
|
selector: "app-investment-proposal-review",
|
|
|
@@ -36,6 +38,31 @@ export class InvestmentProposalReviewComponent implements OnInit {
|
|
|
currentAdIndex = -1;
|
|
|
interval: any;
|
|
|
indexDynamicComponent: number;
|
|
|
+ investmentProposalID: string;
|
|
|
+ investmentExists;
|
|
|
+ state;
|
|
|
+ financials;
|
|
|
+ base_types;
|
|
|
+ countries;
|
|
|
+ companies;
|
|
|
+ rates;
|
|
|
+ revenues;
|
|
|
+ funds;
|
|
|
+ instrumentTypes;
|
|
|
+ markets;
|
|
|
+ emitters;
|
|
|
+ periodicities;
|
|
|
+ format_incomes;
|
|
|
+ payment_terms;
|
|
|
+ operations;
|
|
|
+ gInfo: any;
|
|
|
+ gInstrument: any;
|
|
|
+ gComplement: any;
|
|
|
+ subject: any;
|
|
|
+ investmentName: any;
|
|
|
+ comment: any;
|
|
|
+ justification: any;
|
|
|
+ reviewProposal: {};
|
|
|
|
|
|
constructor(
|
|
|
private router: Router,
|
|
|
@@ -43,33 +70,242 @@ export class InvestmentProposalReviewComponent implements OnInit {
|
|
|
private formDataService: FormInvestmentProposalService,
|
|
|
private componentFactoryResolver: ComponentFactoryResolver,
|
|
|
private instrumentService: InvestmentProposalWorkflowService,
|
|
|
- private loadInstrumentsService: InstrumentsService
|
|
|
+ private loadInstrumentsService: InstrumentsService,
|
|
|
+ private catalogService: CatalogsService,
|
|
|
+ private route: ActivatedRoute,
|
|
|
+ private investmentService: InvestmentsService
|
|
|
) {}
|
|
|
|
|
|
ngOnInit() {
|
|
|
- this.formData = this.formDataService.getFormData();
|
|
|
- this.isFormValid = this.formDataService.isFormValid();
|
|
|
+ //this.formDataService
|
|
|
this.ads = this.loadInstrumentsService.getInstruments();
|
|
|
- this.formData.instrumentos;
|
|
|
+ this.route.params.subscribe(params => {
|
|
|
+ this.investmentProposalID = params["id"];
|
|
|
+ });
|
|
|
+ if (this.investmentProposalID == undefined)
|
|
|
+ this.investmentProposalID = this.route.snapshot.queryParamMap.get("id");
|
|
|
|
|
|
- this.indexDynamicComponent = this.ads.findIndex(
|
|
|
- x => x.component.name == this.formData.instrumentos
|
|
|
- );
|
|
|
- if (this.indexDynamicComponent >= 0) {
|
|
|
- this.loadComponent();
|
|
|
- } else {
|
|
|
- console.log("No existe el componente");
|
|
|
- }
|
|
|
+ if (this.investmentProposalID != undefined) {
|
|
|
+ this.investmentExists = true;
|
|
|
+ this.investmentService
|
|
|
+ .getProposalInvestment(this.investmentProposalID)
|
|
|
+ .subscribe(res => {
|
|
|
+ this.state = res["result"]["id_estado_inversion"]["codigo"];
|
|
|
+
|
|
|
+ this.gInfo = {
|
|
|
+ asunto: res["result"]["asunto"],
|
|
|
+ origenes_fondo:
|
|
|
+ res["result"]["id_origen_fondo"] == null
|
|
|
+ ? ""
|
|
|
+ : res["result"]["id_origen_fondo"]["id_origen_fondo"],
|
|
|
+ name: res["result"]["nombre_inversion"],
|
|
|
+ //date: "",
|
|
|
+ tipo_tasa: res["result"]["id_tipo_tasa"] || "",
|
|
|
+ tipo_renta:
|
|
|
+ res["result"]["id_tipo_renta"] == null
|
|
|
+ ? ""
|
|
|
+ : res["result"]["id_tipo_renta"]["id_tipo_renta"],
|
|
|
+ periodicidad:
|
|
|
+ res["result"]["id_periodicidad"] == null
|
|
|
+ ? ""
|
|
|
+ : res["result"]["id_periodicidad"]["id_periodicidad"],
|
|
|
+
|
|
|
+ instrumentos:
|
|
|
+ res["result"]["id_inversion_instrumento"]["id_tipo_instrumento"][
|
|
|
+ "codigo"
|
|
|
+ ],
|
|
|
+ base_anual:
|
|
|
+ res["result"]["id_tipo_base"] == null
|
|
|
+ ? ""
|
|
|
+ : res["result"]["id_tipo_base"]["id_tipo_base"],
|
|
|
+ casa:
|
|
|
+ res["result"]["id_entidad"] == null
|
|
|
+ ? ""
|
|
|
+ : res["result"]["id_entidad"]["id_entidad_financiera"],
|
|
|
+ formato_ingreso:
|
|
|
+ res["result"]["id_formato_ingreso"] == null
|
|
|
+ ? ""
|
|
|
+ : res["result"]["id_formato_ingreso"]["id_formato_ingreso"]
|
|
|
+ };
|
|
|
+
|
|
|
+ this.gInstrument =
|
|
|
+ res["result"]["id_inversion_instrumento"]["instrumento"];
|
|
|
+
|
|
|
+ this.gInstrument["id_inversion_instrumento"] =
|
|
|
+ res["result"]["id_inversion_instrumento"][
|
|
|
+ "id_inversion_instrumento"
|
|
|
+ ];
|
|
|
+
|
|
|
+ this.gComplement = {
|
|
|
+ tipo_mercado:
|
|
|
+ res["result"]["id_tipo_mercado"] == null
|
|
|
+ ? ""
|
|
|
+ : res["result"]["id_tipo_mercado"]["id_tipo_mercado"],
|
|
|
+ emisores:
|
|
|
+ res["result"]["id_tipo_emisor"] == null
|
|
|
+ ? ""
|
|
|
+ : res["result"]["id_tipo_emisor"]["id_tipo_emisor"],
|
|
|
+ empresa:
|
|
|
+ res["result"]["id_empresa"] == null
|
|
|
+ ? ""
|
|
|
+ : res["result"]["id_empresa"]["id_empresa"],
|
|
|
+ pais:
|
|
|
+ res["result"]["id_pais"] == null
|
|
|
+ ? ""
|
|
|
+ : res["result"]["id_pais"]["id_pais"],
|
|
|
+ plazo:
|
|
|
+ res["result"]["id_plazo"] == null
|
|
|
+ ? ""
|
|
|
+ : res["result"]["id_plazo"]["id_plazo"],
|
|
|
+ operaciones:
|
|
|
+ res["result"]["id_tipo_operacion"] == null
|
|
|
+ ? ""
|
|
|
+ : res["result"]["id_tipo_operacion"]["id_tipo_operacion"],
|
|
|
+ comentarios: res["result"]["comentario"],
|
|
|
+ justificacion: res["result"]["justificacion"]
|
|
|
+ };
|
|
|
+ this.formDataService.setGeneralInfo(this.gInfo);
|
|
|
+
|
|
|
+ this.formDataService.setWork(this.gInstrument);
|
|
|
+
|
|
|
+ this.formDataService.setComplementInfo(this.gComplement);
|
|
|
+
|
|
|
+ this.general = this.formDataService.getGeneralInfo();
|
|
|
+ this.instrument = this.formDataService.getWork();
|
|
|
+ this.complement = this.formDataService.getComplementInfo();
|
|
|
+ this.formData = this.formDataService.getFormData();
|
|
|
|
|
|
- this.general = this.formDataService.getGeneralInfo();
|
|
|
- this.instrument = this.formDataService.getWork();
|
|
|
- this.complement = this.formDataService.getComplementInfo();
|
|
|
+ this.formData.instrumentos;
|
|
|
|
|
|
- this.final = {};
|
|
|
+ this.indexDynamicComponent = this.ads.findIndex(
|
|
|
+ x => x.component.name == this.formData.instrumentos
|
|
|
+ );
|
|
|
+ if (this.indexDynamicComponent >= 0) {
|
|
|
+ this.loadComponent();
|
|
|
+ } else {
|
|
|
+ console.log("No existe el componente");
|
|
|
+ }
|
|
|
+ if (this.general != undefined) {
|
|
|
+ this.subject = this.general.asunto;
|
|
|
+ this.investmentName = this.general.name;
|
|
|
+ this.comment = this.complement.comment;
|
|
|
+ this.justification = this.complement.comment;
|
|
|
+
|
|
|
+ this.catalogService.getFinancialEntities().subscribe(res => {
|
|
|
+ this.financials = res.find(
|
|
|
+ e => e.id_entidad_financiera == this.general.casa
|
|
|
+ );
|
|
|
+ this.financials =
|
|
|
+ this.financials != undefined ? this.financials.nombre : "-";
|
|
|
+ });
|
|
|
+
|
|
|
+ this.catalogService.getBaseTypes().subscribe(res => {
|
|
|
+ this.base_types = res.find(
|
|
|
+ e => e.id_tipo_base == this.general.base_anual
|
|
|
+ );
|
|
|
+ this.base_types =
|
|
|
+ this.base_types != undefined
|
|
|
+ ? ` ${this.base_types.tipo_base} / ${this.base_types.tipo_base_dias}`
|
|
|
+ : "-";
|
|
|
+ });
|
|
|
+
|
|
|
+ this.catalogService.getCountries().subscribe(res => {
|
|
|
+ this.countries = res.find(e => e.id_pais == this.complement.pais);
|
|
|
+ this.countries =
|
|
|
+ this.countries != undefined ? this.countries.nombre : "-";
|
|
|
+ });
|
|
|
+ this.catalogService.getCompanies().subscribe(res => {
|
|
|
+ this.companies = res.find(
|
|
|
+ e => e.id_empresa == this.complement.empresa
|
|
|
+ );
|
|
|
+ this.companies =
|
|
|
+ this.companies != undefined ? this.companies.nombre : "-";
|
|
|
+ });
|
|
|
+ this.catalogService.getRateTypes().subscribe(res => {
|
|
|
+ this.rates = res.find(
|
|
|
+ e => e.id_tipo_tasa == this.general.tipo_tasa
|
|
|
+ );
|
|
|
+ this.rates = this.rates != undefined ? this.rates.nombre : "-";
|
|
|
+ });
|
|
|
+ this.catalogService.getRevenueTypes().subscribe(res => {
|
|
|
+ this.revenues = res.find(
|
|
|
+ e => e.id_tipo_renta == this.general.tipo_renta
|
|
|
+ );
|
|
|
+ this.revenues =
|
|
|
+ this.revenues != undefined ? this.revenues.nombre : "-";
|
|
|
+ });
|
|
|
+
|
|
|
+ this.catalogService.getFundsOrigins().subscribe(res => {
|
|
|
+ this.funds = res.find(
|
|
|
+ e => e.id_origen_fondo == this.general.origenes_fondo
|
|
|
+ );
|
|
|
+ this.funds = this.funds != undefined ? this.funds.nombre : "-";
|
|
|
+ });
|
|
|
+ this.catalogService.getInstrumentTypes().subscribe(res => {
|
|
|
+ this.instrumentTypes = res.find(
|
|
|
+ e => e.codigo == this.general.instrumentos
|
|
|
+ );
|
|
|
+ this.instrumentTypes =
|
|
|
+ this.instrumentTypes != undefined
|
|
|
+ ? this.instrumentTypes.nombre
|
|
|
+ : "-";
|
|
|
+ });
|
|
|
+
|
|
|
+ this.catalogService.getMarketTypes().subscribe(res => {
|
|
|
+ this.markets = res.find(
|
|
|
+ e => e.id_tipo_mercado == this.complement.tipo_mercado
|
|
|
+ );
|
|
|
+ this.markets =
|
|
|
+ this.markets != undefined ? this.markets.nombre : "-";
|
|
|
+ });
|
|
|
+ this.catalogService.getEmitterTypes().subscribe(res => {
|
|
|
+ this.emitters = res.find(
|
|
|
+ e => e.id_tipo_emisor == this.complement.emisores
|
|
|
+ );
|
|
|
+ this.emitters =
|
|
|
+ this.emitters != undefined ? this.emitters.nombre : "-";
|
|
|
+ });
|
|
|
+ this.catalogService.getPeriodicities().subscribe(res => {
|
|
|
+ this.periodicities = res.find(
|
|
|
+ e => e.id_periodicidad == this.general.periodicidad
|
|
|
+ );
|
|
|
+ this.periodicities =
|
|
|
+ this.periodicities != undefined
|
|
|
+ ? this.periodicities.nombre
|
|
|
+ : "-";
|
|
|
+ });
|
|
|
|
|
|
- Object.assign(this.final, this.general, this.instrument, this.complement);
|
|
|
- console.log("Result feature loaded!");
|
|
|
- console.log(this.final);
|
|
|
+ this.catalogService.getPaymentTerms().subscribe(res => {
|
|
|
+ this.payment_terms = res.find(
|
|
|
+ e => e.codigo == this.complement.calificadora_riesgo
|
|
|
+ );
|
|
|
+ this.payment_terms =
|
|
|
+ this.payment_terms != undefined
|
|
|
+ ? this.payment_terms.nombre
|
|
|
+ : "-";
|
|
|
+ });
|
|
|
+ this.catalogService.getOperationTypes().subscribe(res => {
|
|
|
+ this.operations = res.find(
|
|
|
+ e => e.codigo == this.complement.operaciones
|
|
|
+ );
|
|
|
+ this.operations =
|
|
|
+ this.operations != undefined ? this.operations.nombre : "-";
|
|
|
+ });
|
|
|
+ //getIncomeFormat
|
|
|
+ this.catalogService.getIncomeFormat().subscribe(res => {
|
|
|
+ this.format_incomes = res.find(
|
|
|
+ e => e.id_formato_ingreso == this.general.formato_ingreso
|
|
|
+ );
|
|
|
+ this.format_incomes =
|
|
|
+ this.format_incomes != undefined
|
|
|
+ ? this.format_incomes.nombre
|
|
|
+ : "-";
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this.investmentExists = false;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
loadComponent() {
|
|
|
@@ -89,12 +325,12 @@ export class InvestmentProposalReviewComponent implements OnInit {
|
|
|
|
|
|
approve_proposal() {
|
|
|
(async () => {
|
|
|
- const { value: formValues } = await Swal.fire({
|
|
|
- title: "<h3>Aprobar propuesta de inversión</h3>",
|
|
|
+ const { value: comentario } = await Swal.fire({
|
|
|
+ title: "<h3>Enviar a revisión propuesta de inversión</h3>",
|
|
|
icon: "info",
|
|
|
input: "textarea",
|
|
|
showCancelButton: true,
|
|
|
- confirmButtonText: "Aprobar propuesta",
|
|
|
+ confirmButtonText: "Enviar propuesta",
|
|
|
cancelButtonText: "Cancelar",
|
|
|
inputValidator: value => {
|
|
|
if (!value) {
|
|
|
@@ -103,16 +339,45 @@ export class InvestmentProposalReviewComponent implements OnInit {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- if (formValues) {
|
|
|
- Swal.fire(JSON.stringify(formValues));
|
|
|
+ if (comentario) {
|
|
|
+ this.reviewProposal = {
|
|
|
+ id_inversion: this.investmentProposalID,
|
|
|
+ step: "next",
|
|
|
+ comentario: comentario
|
|
|
+ };
|
|
|
+
|
|
|
+ this.investmentService
|
|
|
+ .sendProposalInvestmentToNextStep(this.reviewProposal)
|
|
|
+ .subscribe(
|
|
|
+ success => {
|
|
|
+ if (success) {
|
|
|
+ Swal.fire({
|
|
|
+ allowOutsideClick: false,
|
|
|
+ icon: "success",
|
|
|
+ showCancelButton: false,
|
|
|
+ title: "Exito",
|
|
|
+ confirmButtonText: "La propuesta ha sido aprobada"
|
|
|
+ }).then(result => {
|
|
|
+ Swal.close();
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ err => {
|
|
|
+ Swal.fire({
|
|
|
+ icon: "error",
|
|
|
+ title: "Error al guardar",
|
|
|
+ text: err.message
|
|
|
+ });
|
|
|
+ }
|
|
|
+ );
|
|
|
}
|
|
|
})();
|
|
|
}
|
|
|
|
|
|
dismiss_proposal() {
|
|
|
(async () => {
|
|
|
- const { value: formValues } = await Swal.fire({
|
|
|
- title: "<h3>Rechazar propuesta de inversión</h3>",
|
|
|
+ const { value: comentario } = await Swal.fire({
|
|
|
+ title: "<h3>Enviar a revisión propuesta de inversión</h3>",
|
|
|
icon: "info",
|
|
|
input: "textarea",
|
|
|
showCancelButton: true,
|
|
|
@@ -126,8 +391,37 @@ export class InvestmentProposalReviewComponent implements OnInit {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- if (formValues) {
|
|
|
- Swal.fire(JSON.stringify(formValues));
|
|
|
+ if (comentario) {
|
|
|
+ this.reviewProposal = {
|
|
|
+ id_inversion: this.investmentProposalID,
|
|
|
+ step: "next",
|
|
|
+ comentario: comentario
|
|
|
+ };
|
|
|
+
|
|
|
+ this.investmentService
|
|
|
+ .sendProposalInvestmentToNextStep(this.reviewProposal)
|
|
|
+ .subscribe(
|
|
|
+ success => {
|
|
|
+ if (success) {
|
|
|
+ Swal.fire({
|
|
|
+ allowOutsideClick: false,
|
|
|
+ icon: "success",
|
|
|
+ showCancelButton: false,
|
|
|
+ title: "Exito",
|
|
|
+ confirmButtonText: "La propuesta ha sido aprobada"
|
|
|
+ }).then(result => {
|
|
|
+ Swal.close();
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ err => {
|
|
|
+ Swal.fire({
|
|
|
+ icon: "error",
|
|
|
+ title: "Error en el servidor",
|
|
|
+ text: err.message
|
|
|
+ });
|
|
|
+ }
|
|
|
+ );
|
|
|
}
|
|
|
})();
|
|
|
}
|