|  | @ -29,21 +29,14 @@ import { REQUEST } from '@nestjs/core'; | 
			
		
	
		
		
			
				
					|  |  | import { Currency, DataSource, Type as TypeOfOrder } from '@prisma/client'; |  |  | import { Currency, DataSource, Type as TypeOfOrder } from '@prisma/client'; | 
			
		
	
		
		
			
				
					|  |  | import Big from 'big.js'; |  |  | import Big from 'big.js'; | 
			
		
	
		
		
			
				
					|  |  | import { |  |  | import { | 
			
		
	
		
		
			
				
					|  |  |   add, |  |  |  | 
			
		
	
		
		
			
				
					|  |  |   endOfToday, |  |  |   endOfToday, | 
			
		
	
		
		
			
				
					|  |  |   format, |  |  |   format, | 
			
		
	
		
		
			
				
					|  |  |   getDate, |  |  |  | 
			
		
	
		
		
			
				
					|  |  |   getMonth, |  |  |  | 
			
		
	
		
		
			
				
					|  |  |   getYear, |  |  |  | 
			
		
	
		
		
			
				
					|  |  |   isAfter, |  |  |   isAfter, | 
			
		
	
		
		
			
				
					|  |  |   isBefore, |  |  |   isBefore, | 
			
		
	
		
		
			
				
					|  |  |   max, |  |  |   max, | 
			
		
	
		
		
			
				
					|  |  |   parse, |  |  |   parse, | 
			
		
	
		
		
			
				
					|  |  |   parseISO, |  |  |   parseISO, | 
			
		
	
		
		
			
				
					|  |  |   setDate, |  |  |  | 
			
		
	
		
		
			
				
					|  |  |   setDayOfYear, |  |  |   setDayOfYear, | 
			
		
	
		
		
			
				
					|  |  |   setMonth, |  |  |  | 
			
		
	
		
		
			
				
					|  |  |   sub, |  |  |  | 
			
		
	
		
		
			
				
					|  |  |   subDays, |  |  |   subDays, | 
			
		
	
		
		
			
				
					|  |  |   subYears |  |  |   subYears | 
			
		
	
		
		
			
				
					|  |  | } from 'date-fns'; |  |  | } from 'date-fns'; | 
			
		
	
	
		
		
			
				
					|  | @ -669,53 +662,6 @@ export class PortfolioService { | 
			
		
	
		
		
			
				
					|  |  |     }; |  |  |     }; | 
			
		
	
		
		
			
				
					|  |  |   } |  |  |   } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |   private convertDateRangeToDate(aDateRange: DateRange, aMinDate: Date) { |  |  |  | 
			
		
	
		
		
			
				
					|  |  |     let currentDate = new Date(); |  |  |  | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |     const normalizedMinDate = |  |  |  | 
			
		
	
		
		
			
				
					|  |  |       getDate(aMinDate) === 1 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         ? aMinDate |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         : add(setDate(aMinDate, 1), { months: 1 }); |  |  |  | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |     const year = getYear(currentDate); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |     const month = getMonth(currentDate); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |     const day = getDate(currentDate); |  |  |  | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |     currentDate = new Date(Date.UTC(year, month, day, 0)); |  |  |  | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |     switch (aDateRange) { |  |  |  | 
			
		
	
		
		
			
				
					|  |  |       case '1d': |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         return sub(currentDate, { |  |  |  | 
			
		
	
		
		
			
				
					|  |  |           days: 1 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         }); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |       case 'ytd': |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         currentDate = setDate(currentDate, 1); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         currentDate = setMonth(currentDate, 0); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         return isAfter(currentDate, normalizedMinDate) |  |  |  | 
			
		
	
		
		
			
				
					|  |  |           ? currentDate |  |  |  | 
			
		
	
		
		
			
				
					|  |  |           : undefined; |  |  |  | 
			
		
	
		
		
			
				
					|  |  |       case '1y': |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         currentDate = setDate(currentDate, 1); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         currentDate = sub(currentDate, { |  |  |  | 
			
		
	
		
		
			
				
					|  |  |           years: 1 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         }); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         return isAfter(currentDate, normalizedMinDate) |  |  |  | 
			
		
	
		
		
			
				
					|  |  |           ? currentDate |  |  |  | 
			
		
	
		
		
			
				
					|  |  |           : undefined; |  |  |  | 
			
		
	
		
		
			
				
					|  |  |       case '5y': |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         currentDate = setDate(currentDate, 1); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         currentDate = sub(currentDate, { |  |  |  | 
			
		
	
		
		
			
				
					|  |  |           years: 5 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         }); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         return isAfter(currentDate, normalizedMinDate) |  |  |  | 
			
		
	
		
		
			
				
					|  |  |           ? currentDate |  |  |  | 
			
		
	
		
		
			
				
					|  |  |           : undefined; |  |  |  | 
			
		
	
		
		
			
				
					|  |  |       default: |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         // Gets handled as all data
 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         return undefined; |  |  |  | 
			
		
	
		
		
			
				
					|  |  |     } |  |  |  | 
			
		
	
		
		
			
				
					|  |  |   } |  |  |  | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |   private getAccounts( |  |  |   private getAccounts( | 
			
		
	
		
		
			
				
					|  |  |     orders: OrderWithAccount[], |  |  |     orders: OrderWithAccount[], | 
			
		
	
		
		
			
				
					|  |  |     portfolioItemsNow: { [p: string]: TimelinePosition }, |  |  |     portfolioItemsNow: { [p: string]: TimelinePosition }, | 
			
		
	
	
		
		
			
				
					|  | 
 |