| 
						
						
						
					 | 
					@ -1,7 +1,8 @@ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import { ConfigurationService } from '@ghostfolio/api/services/configuration/configuration.service'; | 
					 | 
					 | 
					import { ConfigurationService } from '@ghostfolio/api/services/configuration/configuration.service'; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import { PrismaService } from '@ghostfolio/api/services/prisma/prisma.service'; | 
					 | 
					 | 
					import { PrismaService } from '@ghostfolio/api/services/prisma/prisma.service'; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import { DEFAULT_LANGUAGE_CODE } from '@ghostfolio/common/config'; | 
					 | 
					 | 
					import { DEFAULT_LANGUAGE_CODE } from '@ghostfolio/common/config'; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					import { UserWithSettings } from '@ghostfolio/common/types'; | 
					 | 
					 | 
					import { parseDate } from '@ghostfolio/common/helper'; | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					import { SubscriptionOffer, UserWithSettings } from '@ghostfolio/common/types'; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import { SubscriptionType } from '@ghostfolio/common/types/subscription-type.type'; | 
					 | 
					 | 
					import { SubscriptionType } from '@ghostfolio/common/types/subscription-type.type'; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import { Injectable, Logger } from '@nestjs/common'; | 
					 | 
					 | 
					import { Injectable, Logger } from '@nestjs/common'; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import { Subscription } from '@prisma/client'; | 
					 | 
					 | 
					import { Subscription } from '@prisma/client'; | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					@ -107,17 +108,27 @@ export class SubscriptionService { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    } | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					  } | 
					 | 
					 | 
					  } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					  public getSubscription( | 
					 | 
					 | 
					  public getSubscription({ | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					    aSubscriptions: Subscription[] | 
					 | 
					 | 
					    createdAt, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					  ): UserWithSettings['subscription'] { | 
					 | 
					 | 
					    subscriptions | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					    if (aSubscriptions.length > 0) { | 
					 | 
					 | 
					  }: { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					      const { expiresAt, price } = aSubscriptions.reduce((a, b) => { | 
					 | 
					 | 
					    createdAt: UserWithSettings['createdAt']; | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    subscriptions: Subscription[]; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					  }): UserWithSettings['subscription'] { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    if (subscriptions.length > 0) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      const { expiresAt, price } = subscriptions.reduce((a, b) => { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        return new Date(a.expiresAt) > new Date(b.expiresAt) ? a : b; | 
					 | 
					 | 
					        return new Date(a.expiresAt) > new Date(b.expiresAt) ? a : b; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      }); | 
					 | 
					 | 
					      }); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      let offer: SubscriptionOffer = price ? 'renewal' : 'default'; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      if (isBefore(createdAt, parseDate('2023-01-01'))) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        offer = 'renewal-early-bird'; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      return { | 
					 | 
					 | 
					      return { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        expiresAt, | 
					 | 
					 | 
					        expiresAt, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					        offer: price ? 'renewal' : 'default', | 
					 | 
					 | 
					        offer, | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					        type: isBefore(new Date(), expiresAt) | 
					 | 
					 | 
					        type: isBefore(new Date(), expiresAt) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					          ? SubscriptionType.Premium | 
					 | 
					 | 
					          ? SubscriptionType.Premium | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					          : SubscriptionType.Basic | 
					 | 
					 | 
					          : SubscriptionType.Basic | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					
  |