{ "version": 3, "sources": ["src/app/dashboard/funds/GpFundReqRes.model.ts", "src/app/services/gp/gp-fund-data.service.ts"], "sourcesContent": ["import {ProjectedPerformance} from 'src/app/shared/models/ProjectedPerformance.model';\nimport {LenderInformation} from 'src/app/shared/models/LenderInformation.model';\nimport {ProjectBudget} from 'src/app/shared/models/ProjectBudget.model';\nimport {CurrencyModel} from 'src/app/shared/models/CurrencyModel';\nimport FundInvestmentStrategyType from 'src/app/shared/enums/FundInvestmentStrategyType.enum';\nimport {HoldingFileReqRes} from 'src/app/dashboard/shared/holding/HoldingFileReqRes.model';\nimport {GpAssetListItemReqRes} from '../assets/GpAssetReqRes.model';\nimport {InvestingEntityReqRes} from '../models/InvestingEntityReqRes.model';\nimport {GpHoldingListItemReqRes} from '../shared/holding/GpHoldingListItem.model';\nimport {GpHolding} from '../shared/holding/GpHolding.model';\nimport { CommitmentsEnabled } from 'src/app/shared/enums/CommitmentsEnabled.enum';\nimport { OwnershipCalculationType } from 'src/app/shared/enums/OwnershipCalculationType.enum';\nimport { LpOwnershipVisibility } from 'src/app/shared/enums/LpOwnershipVisibility.enum';\n\nexport class GpFundListItemReqRes extends GpHoldingListItemReqRes {\n public email: string;\n public isCollectDeposists: boolean;\n public canSetAsPrivate: boolean;\n public attachments: HoldingFileReqRes[];\n\n // Front only property:\n public isExampleAsset = false;\n\n public percentsFunded: number;\n public fundraisingTargetAmount: number;\n public initialCurrency: CurrencyModel;\n public estimatedClosingDate: Date;\n public investingEntityId: number;\n}\n\nexport class GpFundReqRes extends GpHolding {\n public isCollectDeposists: boolean;\n public canSetAsPrivate: boolean;\n\n // Front only property:\n public isExampleAsset = false;\n\n public investmentStrategyType: FundInvestmentStrategyType;\n public investmentStrategyTypeOther: string;\n\n public projectedPerformance: ProjectedPerformance;\n public lenderInformation: LenderInformation;\n\n public projectBudgetOriginal: ProjectBudget;\n public projectBudgetUpdated: ProjectBudget;\n\n // #region Cumulative information:\n public plannedCostsToDate: number;\n public actualCostsToDate: number;\n\n public gpEquityFromTotalEquity: number;\n public estimatedMarketValue: number;\n\n public cumulativeProjectedPerformance: ProjectedPerformance;\n // #endregion\n\n public initialCurrency: CurrencyModel;\n public initialCurrencyId: number;\n public assets: GpAssetListItemReqRes[];\n public investingEntity: InvestingEntityReqRes;\n public relatedHoldings: GpHoldingListItemReqRes[];\n\n public commitmentsEnabled: CommitmentsEnabled;\n public ownershipCalculationType: OwnershipCalculationType;\n public lpOwnershipVisibility: LpOwnershipVisibility;\n public displayCommitments: boolean;\n}\n", "import {Injectable} from '@angular/core';\nimport {Router} from '@angular/router';\nimport {Observable, throwError} from 'rxjs';\nimport {catchError, shareReplay, map, retryWhen, tap} from 'rxjs/operators';\n\nimport {HttpService} from '../http.service';\nimport FundOrderBy from 'src/app/shared/enums/FundOrderBy.enum';\nimport {GpFundListItemReqRes, GpFundReqRes} from 'src/app/dashboard/funds/GpFundReqRes.model';\nimport {GpFundPollingReqRes} from 'src/app/dashboard/funds/gp-fund/GpFundPollingReqRes.model';\nimport HTTP_STATUS_CODES from 'src/app/shared/enums/HttpStatusCodesEnum';\nimport {RoutingService} from '../routing.service';\nimport {FundAndFundraisingReqRes} from 'src/app/dashboard/funds/components/create-fund/FundAndFundraisingRequest';\nimport HoldingStatus from 'src/app/shared/enums/HoldingStatus.enum';\nimport HoldingDiscriminator from 'src/app/shared/enums/HoldingDiscriminator.enum';\nimport {GpHoldingListItemReqRes} from 'src/app/dashboard/shared/holding/GpHoldingListItem.model';\nimport {SearchOptionsRequest} from 'src/app/shared/models/SearchOptionsRequest.model';\nimport {IdValue} from '../../shared/models/IdValue.model';\nimport {GpHoldingOverviewItemReqRes} from 'src/app/dashboard/shared/holding/GpHoldingOverviewItemReqRes';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class GpFundDataService {\n public readonly FUND_BASE_ENDPOINT = 'gp/funds';\n private readonly CREATE_FUND_ENDPOINT = this.FUND_BASE_ENDPOINT;\n public readonly discriminator = HoldingDiscriminator.Fund;\n\n constructor(private http: HttpService, private router: Router, private routingService: RoutingService) {\n }\n\n getFundsList(orderBy: FundOrderBy = FundOrderBy.CreatedDateNewerFirst): Observable {\n return this.http.getTyped(`${this.FUND_BASE_ENDPOINT}?orderBy=${orderBy}`)\n .pipe(\n map((funds) => funds.map(fund =>\n ({...fund, discriminator: this.discriminator}))),\n catchError((err) => {\n return throwError(err);\n })\n );\n }\n\n getDealsList(orderBy: FundOrderBy = FundOrderBy.NameAsc): Observable {\n return this.http.getTyped(`${this.FUND_BASE_ENDPOINT}/overview?orderBy=${orderBy}`).pipe(\n map((assets) => assets.map((asset) =>\n ({...asset, discriminator: this.discriminator}))),\n catchError((err) => {\n return throwError(() => err);\n })\n );\n }\n\n getDealsBalances() {\n return this.http.getTyped[]>(`${this.FUND_BASE_ENDPOINT}/overview/balances`).pipe(\n catchError((err) => {\n return throwError(() => err);\n })\n );\n }\n\n detectChanges(fundId: number, fundraisingId: number, distributionId: number, changedSince: Date): Observable {\n const pollRequest = {\n fundraisingId,\n distributionId,\n changedSince\n };\n\n return this.http\n .postTyped(`${this.FUND_BASE_ENDPOINT}/${fundId}/detectChanges`, pollRequest)\n .pipe(\n map((response) => {\n return response ?({...response, fund: {...response.fund, discriminator: this.discriminator}}) : null\n }),\n retryWhen((error) =>\n error.pipe(\n tap((err) => {\n if (err.status !== 0) { // When Azure app service reaches timeout (230 seconds) error received with 0 status\n throw error;\n }\n })\n )),\n catchError((err) => {\n // if (err.status === 0) {\n // console.log('detect changes request has failed');\n // return this.detectChanges(fundId, fundraisingId, changedSince);\n // }\n // else\n if (err.status === HTTP_STATUS_CODES.NOT_FOUND) {\n // if fund polling (initial fundraising): return to funds list\n if (fundraisingId === 0) {\n this.router.navigateByUrl(this.routingService.gpFundsPage);\n } else {\n this.router.navigateByUrl(this.routingService.gpFundPage(fundId));\n }\n }\n return throwError(() => err);\n })\n );\n }\n\n getFundById(fundId: number): Observable {\n const url = `${this.FUND_BASE_ENDPOINT}/${fundId}`;\n return this.http.getTyped(url).pipe(\n map((fund) => this.addDiscriminatorToFund(fund)),\n shareReplay());\n }\n\n /** Get a list of all holdings that the fund is involved in.\n * They can be fund-assets inside the fund, or holding in which the fund invested. */\n getFundHoldings(fundId: number, options: SearchOptionsRequest) {\n options.pageSize = 1000;\n options.pageNumber = 0;\n let queryString = `?sortOrder=${options.sortOrder}&orderBy=${options.orderBy}&pageNumber=${options.pageNumber}&pageSize=${options.pageSize}`;\n const url = `${this.FUND_BASE_ENDPOINT}/${fundId}/holdings` + queryString;\n return this.http.getTyped(url).pipe(\n shareReplay());\n }\n\n createFund(model: FundAndFundraisingReqRes): Observable {\n return this.http.postTyped(this.CREATE_FUND_ENDPOINT, model).pipe(\n map((response) => this.addDiscriminatorToFundAndFundraising(response)),\n catchError((err) => {\n return throwError(err);\n })\n );\n }\n\n createDraftFund(model: GpFundReqRes): Observable {\n return this.http.postTyped(`${this.CREATE_FUND_ENDPOINT}/draft`, model).pipe(\n map((asset) => this.addDiscriminatorToFund(asset)),\n catchError((err) => {\n return throwError(err);\n })\n );\n }\n\n updateFund(fundId: number, model: FundAndFundraisingReqRes, skipNotification = false): Observable {\n return this.http.putTyped(`${this.FUND_BASE_ENDPOINT}/${fundId}?skipNotification=${skipNotification}`, model).pipe(\n map((response) => this.addDiscriminatorToFundAndFundraising(response)),\n catchError((err) => {\n return throwError(err);\n })\n );\n }\n\n updateDraftFund(fundId: number, model: GpFundReqRes): Observable {\n return this.http.putTyped(`${this.FUND_BASE_ENDPOINT}/draft/${fundId}`, model).pipe(\n catchError((err) => {\n return throwError(err);\n })\n );\n }\n\n updateFundVisibility(model: GpHoldingOverviewItemReqRes): Observable {\n return this.http.putTyped(`${this.FUND_BASE_ENDPOINT}/visibility`, model).pipe(\n catchError((err) => {\n return throwError(() => err);\n })\n );\n }\n\n moveFundToUnderManagement(fundId: number, model: FundAndFundraisingReqRes): Observable {\n return this.http.patchTyped(`${this.FUND_BASE_ENDPOINT}/${fundId}/move-to-under-management`, model).pipe(\n map((response) => this.addDiscriminatorToFundAndFundraising(response)),\n catchError((err) => {\n return throwError(err);\n })\n );\n }\n\n moveFundraisingToCompleted(fundId: number, model: FundAndFundraisingReqRes): Observable {\n return this.http.patchTyped(`${this.FUND_BASE_ENDPOINT}/${fundId}/move-fundraising-to-completed`, model).pipe(\n map((response) => this.addDiscriminatorToFundAndFundraising(response)),\n catchError((err) => {\n return throwError(err);\n })\n );\n }\n\n updateStatus(fundId: number, holdingStatus: HoldingStatus, draftSendEmailsWhenMovingToUnderManagement = false) {\n const model = new GpFundReqRes();\n model.id = fundId;\n model.status = holdingStatus;\n return this.http.putTyped(\n `${this.FUND_BASE_ENDPOINT}/${fundId}/status?sendEmails=${draftSendEmailsWhenMovingToUnderManagement}`, model)\n .pipe(\n map((fund) => this.addDiscriminatorToFund(fund)),\n catchError((err) => {\n return throwError(err);\n })\n );\n }\n\n deleteFund(fundId: number) {\n return this.http.deleteTyped(`${this.FUND_BASE_ENDPOINT}/${fundId}`).pipe(\n catchError((err) => {\n return throwError(err);\n })\n );\n }\n\n isFundNameExists(fundName: string, fundIdToExclude: number = 0) {\n fundName = fundName.trim();\n const url = `${this.FUND_BASE_ENDPOINT}/fund-name-exists-check`;\n return this.http.postTyped(url, {fundName, fundIdToExclude}).pipe(shareReplay(1));\n }\n\n /** Get a list of all the funds that can invest in other holdings */\n getFundsForInvestment(): Observable {\n return this.http.getTyped(`${this.FUND_BASE_ENDPOINT}/as-investors`).pipe(\n catchError((err) => {\n return throwError(err);\n })\n );\n }\n\n private addDiscriminatorToFund(fund: GpHoldingListItemReqRes) {\n return {...fund, discriminator: this.discriminator} as GpFundReqRes;\n }\n\n private addDiscriminatorToFundAndFundraising(fundAndFundraising: FundAndFundraisingReqRes) {\n return {\n ...fundAndFundraising,\n fund: this.addDiscriminatorToFund(fundAndFundraising.fund)\n } as FundAndFundraisingReqRes;\n }\n}\n"], "mappings": "4PA8BM,IAAOA,EAAP,cAA4BC,CAAS,CAA3CC,aAAA,qBAKS,KAAAC,e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AAAC,WAFhB,MAAM,CAAA,EAEd,IAAOrF,EAAPsF,SAAOtF,CAAiB,GAAA", "names": ["GpFundReqRes", "GpHolding", "constructor", "isExampleAsset", "GpFundDataService", "constructor", "http", "router", "routingService", "FUND_BASE_ENDPOINT", "CREATE_FUND_ENDPOINT", "discriminator", "HoldingDiscriminator", "Fund", "getFundsList", "orderBy", "FundOrderBy", "CreatedDateNewerFirst", "getTyped", "pipe", "map", "funds", "fund", "__spreadProps", "__spreadValues", "catchError", "err", "throwError", "getDealsList", "NameAsc", "assets", "asset", "getDealsBalances", "detectChanges", "fundId", "fundraisingId", "distributionId", "changedSince", "pollRequest", "postTyped", "response", "retryWhen", "error", "tap", "status", "navigateByUrl", "gpFundsPage", "gpFundPage", "getFundById", "url", "addDiscriminatorToFund", "shareReplay", "getFundHoldings", "options", "pageSize", "pageNumber", "queryString", "sortOrder", "createFund", "model", "addDiscriminatorToFundAndFundraising", "createDraftFund", "updateFund", "skipNotification", "putTyped", "updateDraftFund", "updateFundVisibility", "moveFundToUnderManagement", "patchTyped", "moveFundraisingToCompleted", "updateStatus", "holdingStatus", "draftSendEmailsWhenMovingToUnderManagement", "GpFundReqRes", "id", "deleteFund", "deleteTyped", "isFundNameExists", "fundName", "fundIdToExclude", "trim", "getFundsForInvestment", "fundAndFundraising", "\u0275\u0275inject", "HttpService", "Router", "RoutingService", "factory", "\u0275fac", "providedIn", "_GpFundDataService"] }