subscriptions.ts 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  1. import {
  2. CustomSubscription,
  3. GroupSubscription,
  4. RecurlySubscription,
  5. } from '../../../../../types/subscription/dashboard/subscription'
  6. import dateformat from 'dateformat'
  7. const today = new Date()
  8. const oneYearFromToday = new Date().setFullYear(today.getFullYear() + 1)
  9. const nextPaymentDueAt = dateformat(oneYearFromToday, 'dS mmmm yyyy')
  10. const nextPaymentDueDate = dateformat(oneYearFromToday, 'dS mmmm yyyy')
  11. const sevenDaysFromToday = new Date().setDate(today.getDate() + 7)
  12. const sevenDaysFromTodayFormatted = dateformat(
  13. sevenDaysFromToday,
  14. 'dS mmmm yyyy'
  15. )
  16. export const annualActiveSubscription: RecurlySubscription = {
  17. manager_ids: ['abc123'],
  18. member_ids: [],
  19. invited_emails: [],
  20. groupPlan: false,
  21. membersLimit: 0,
  22. _id: 'def456',
  23. admin_id: 'abc123',
  24. teamInvites: [],
  25. planCode: 'collaborator-annual',
  26. recurlySubscription_id: 'ghi789',
  27. plan: {
  28. planCode: 'collaborator-annual',
  29. name: 'Standard (Collaborator) Annual',
  30. price_in_cents: 21900,
  31. annual: true,
  32. featureDescription: [],
  33. },
  34. recurly: {
  35. tax: 0,
  36. taxRate: 0,
  37. billingDetailsLink: '/user/subscription/recurly/billing-details',
  38. accountManagementLink: '/user/subscription/recurly/account-management',
  39. additionalLicenses: 0,
  40. totalLicenses: 0,
  41. nextPaymentDueAt,
  42. nextPaymentDueDate,
  43. currency: 'USD',
  44. state: 'active',
  45. trialEndsAtFormatted: null,
  46. trial_ends_at: null,
  47. activeCoupons: [],
  48. account: {
  49. email: 'fake@example.com',
  50. created_at: '2024-12-31T09:40:27.000Z',
  51. has_canceled_subscription: { _: 'false', $: { type: 'boolean' } },
  52. has_past_due_invoice: { _: 'false', $: { type: 'boolean' } },
  53. },
  54. displayPrice: '$199.00',
  55. },
  56. }
  57. export const annualActiveSubscriptionEuro: RecurlySubscription = {
  58. manager_ids: ['abc123'],
  59. member_ids: [],
  60. invited_emails: [],
  61. groupPlan: false,
  62. membersLimit: 0,
  63. _id: 'def456',
  64. admin_id: 'abc123',
  65. teamInvites: [],
  66. planCode: 'collaborator-annual',
  67. recurlySubscription_id: 'ghi789',
  68. plan: {
  69. planCode: 'collaborator-annual',
  70. name: 'Standard (Collaborator) Annual',
  71. price_in_cents: 21900,
  72. annual: true,
  73. featureDescription: [],
  74. },
  75. recurly: {
  76. tax: 4296,
  77. taxRate: 0.24,
  78. billingDetailsLink: '/user/subscription/recurly/billing-details',
  79. accountManagementLink: '/user/subscription/recurly/account-management',
  80. additionalLicenses: 0,
  81. totalLicenses: 0,
  82. nextPaymentDueAt,
  83. nextPaymentDueDate,
  84. currency: 'EUR',
  85. state: 'active',
  86. trialEndsAtFormatted: null,
  87. trial_ends_at: null,
  88. activeCoupons: [],
  89. account: {
  90. email: 'fake@example.com',
  91. created_at: '2024-12-31T09:40:27.000Z',
  92. has_canceled_subscription: { _: 'false', $: { type: 'boolean' } },
  93. has_past_due_invoice: { _: 'false', $: { type: 'boolean' } },
  94. },
  95. displayPrice: '€221.96',
  96. },
  97. }
  98. export const annualActiveSubscriptionPro: RecurlySubscription = {
  99. manager_ids: ['abc123'],
  100. member_ids: [],
  101. invited_emails: [],
  102. groupPlan: false,
  103. membersLimit: 0,
  104. _id: 'def456',
  105. admin_id: 'abc123',
  106. teamInvites: [],
  107. planCode: 'professional',
  108. recurlySubscription_id: 'ghi789',
  109. plan: {
  110. planCode: 'professional',
  111. name: 'Professional',
  112. price_in_cents: 4500,
  113. featureDescription: [],
  114. },
  115. recurly: {
  116. tax: 0,
  117. taxRate: 0,
  118. billingDetailsLink: '/user/subscription/recurly/billing-details',
  119. accountManagementLink: '/user/subscription/recurly/account-management',
  120. additionalLicenses: 0,
  121. totalLicenses: 0,
  122. nextPaymentDueAt,
  123. nextPaymentDueDate,
  124. currency: 'USD',
  125. state: 'active',
  126. trialEndsAtFormatted: null,
  127. trial_ends_at: null,
  128. activeCoupons: [],
  129. account: {
  130. email: 'fake@example.com',
  131. created_at: '2024-12-31T09:40:27.000Z',
  132. has_canceled_subscription: { _: 'false', $: { type: 'boolean' } },
  133. has_past_due_invoice: { _: 'false', $: { type: 'boolean' } },
  134. },
  135. displayPrice: '$42.00',
  136. },
  137. }
  138. export const pastDueExpiredSubscription: RecurlySubscription = {
  139. manager_ids: ['abc123'],
  140. member_ids: [],
  141. invited_emails: [],
  142. groupPlan: false,
  143. membersLimit: 0,
  144. _id: 'def456',
  145. admin_id: 'abc123',
  146. teamInvites: [],
  147. planCode: 'collaborator-annual',
  148. recurlySubscription_id: 'ghi789',
  149. plan: {
  150. planCode: 'collaborator-annual',
  151. name: 'Standard (Collaborator) Annual',
  152. price_in_cents: 21900,
  153. annual: true,
  154. featureDescription: [],
  155. },
  156. recurly: {
  157. tax: 0,
  158. taxRate: 0,
  159. billingDetailsLink: '/user/subscription/recurly/billing-details',
  160. accountManagementLink: '/user/subscription/recurly/account-management',
  161. additionalLicenses: 0,
  162. totalLicenses: 0,
  163. nextPaymentDueAt,
  164. nextPaymentDueDate,
  165. currency: 'USD',
  166. state: 'expired',
  167. trialEndsAtFormatted: null,
  168. trial_ends_at: null,
  169. activeCoupons: [],
  170. account: {
  171. email: 'fake@example.com',
  172. created_at: '2024-12-31T09:40:27.000Z',
  173. has_canceled_subscription: { _: 'false', $: { type: 'boolean' } },
  174. has_past_due_invoice: { _: 'true', $: { type: 'boolean' } },
  175. },
  176. displayPrice: '$199.00',
  177. },
  178. }
  179. export const canceledSubscription: RecurlySubscription = {
  180. manager_ids: ['abc123'],
  181. member_ids: [],
  182. invited_emails: [],
  183. groupPlan: false,
  184. membersLimit: 0,
  185. _id: 'def456',
  186. admin_id: 'abc123',
  187. teamInvites: [],
  188. planCode: 'collaborator-annual',
  189. recurlySubscription_id: 'ghi789',
  190. plan: {
  191. planCode: 'collaborator-annual',
  192. name: 'Standard (Collaborator) Annual',
  193. price_in_cents: 21900,
  194. annual: true,
  195. featureDescription: [],
  196. },
  197. recurly: {
  198. tax: 0,
  199. taxRate: 0,
  200. billingDetailsLink: '/user/subscription/recurly/billing-details',
  201. accountManagementLink: '/user/subscription/recurly/account-management',
  202. additionalLicenses: 0,
  203. totalLicenses: 0,
  204. nextPaymentDueAt,
  205. nextPaymentDueDate,
  206. currency: 'USD',
  207. state: 'canceled',
  208. trialEndsAtFormatted: null,
  209. trial_ends_at: null,
  210. activeCoupons: [],
  211. account: {
  212. email: 'fake@example.com',
  213. created_at: '2024-12-31T09:40:27.000Z',
  214. has_canceled_subscription: { _: 'true', $: { type: 'boolean' } },
  215. has_past_due_invoice: { _: 'false', $: { type: 'boolean' } },
  216. },
  217. displayPrice: '$199.00',
  218. },
  219. }
  220. export const pendingSubscriptionChange: RecurlySubscription = {
  221. manager_ids: ['abc123'],
  222. member_ids: [],
  223. invited_emails: [],
  224. groupPlan: false,
  225. membersLimit: 0,
  226. _id: 'def456',
  227. admin_id: 'abc123',
  228. teamInvites: [],
  229. planCode: 'collaborator-annual',
  230. recurlySubscription_id: 'ghi789',
  231. plan: {
  232. planCode: 'collaborator-annual',
  233. name: 'Standard (Collaborator) Annual',
  234. price_in_cents: 21900,
  235. annual: true,
  236. featureDescription: [],
  237. },
  238. recurly: {
  239. tax: 0,
  240. taxRate: 0,
  241. billingDetailsLink: '/user/subscription/recurly/billing-details',
  242. accountManagementLink: '/user/subscription/recurly/account-management',
  243. additionalLicenses: 0,
  244. totalLicenses: 0,
  245. nextPaymentDueAt,
  246. nextPaymentDueDate,
  247. currency: 'USD',
  248. state: 'active',
  249. trialEndsAtFormatted: null,
  250. trial_ends_at: null,
  251. activeCoupons: [],
  252. account: {
  253. email: 'fake@example.com',
  254. created_at: '2024-12-31T09:40:27.000Z',
  255. has_canceled_subscription: { _: 'false', $: { type: 'boolean' } },
  256. has_past_due_invoice: { _: 'false', $: { type: 'boolean' } },
  257. },
  258. displayPrice: '$199.00',
  259. },
  260. pendingPlan: {
  261. planCode: 'professional-annual',
  262. name: 'Professional Annual',
  263. price_in_cents: 42900,
  264. annual: true,
  265. featureDescription: [],
  266. },
  267. }
  268. export const groupActiveSubscription: GroupSubscription = {
  269. manager_ids: ['abc123'],
  270. member_ids: ['abc123'],
  271. invited_emails: [],
  272. groupPlan: true,
  273. teamName: 'GAS',
  274. membersLimit: 10,
  275. _id: 'bcd567',
  276. admin_id: 'abc123',
  277. teamInvites: [],
  278. planCode: 'group_collaborator_10_enterprise',
  279. recurlySubscription_id: 'ghi789',
  280. plan: {
  281. planCode: 'group_collaborator_10_enterprise',
  282. name: 'Overleaf Standard (Collaborator) - Group Account (10 licenses) - Enterprise',
  283. hideFromUsers: true,
  284. price_in_cents: 129000,
  285. annual: true,
  286. groupPlan: true,
  287. membersLimit: 10,
  288. membersLimitAddOn: 'additional-license',
  289. },
  290. recurly: {
  291. tax: 0,
  292. taxRate: 0,
  293. billingDetailsLink: '/user/subscription/recurly/billing-details',
  294. accountManagementLink: '/user/subscription/recurly/account-management',
  295. additionalLicenses: 0,
  296. totalLicenses: 10,
  297. nextPaymentDueAt,
  298. nextPaymentDueDate,
  299. currency: 'USD',
  300. state: 'active',
  301. trialEndsAtFormatted: null,
  302. trial_ends_at: null,
  303. activeCoupons: [],
  304. account: {
  305. email: 'fake@example.com',
  306. created_at: '2024-12-31T09:40:27.000Z',
  307. has_canceled_subscription: { _: 'false', $: { type: 'boolean' } },
  308. has_past_due_invoice: { _: 'false', $: { type: 'boolean' } },
  309. },
  310. displayPrice: '$1290.00',
  311. },
  312. }
  313. export const groupActiveSubscriptionWithPendingLicenseChange: GroupSubscription =
  314. {
  315. manager_ids: ['abc123'],
  316. member_ids: ['abc123'],
  317. invited_emails: [],
  318. groupPlan: true,
  319. teamName: 'GASWPLC',
  320. membersLimit: 10,
  321. _id: 'def456',
  322. admin_id: 'abc123',
  323. teamInvites: [],
  324. planCode: 'group_collaborator_10_enterprise',
  325. recurlySubscription_id: 'ghi789',
  326. plan: {
  327. planCode: 'group_collaborator_10_enterprise',
  328. name: 'Overleaf Standard (Collaborator) - Group Account (10 licenses) - Enterprise',
  329. hideFromUsers: true,
  330. price_in_cents: 129000,
  331. annual: true,
  332. groupPlan: true,
  333. membersLimit: 10,
  334. membersLimitAddOn: 'additional-license',
  335. },
  336. recurly: {
  337. tax: 0,
  338. taxRate: 0,
  339. billingDetailsLink: '/user/subscription/recurly/billing-details',
  340. accountManagementLink: '/user/subscription/recurly/account-management',
  341. additionalLicenses: 11,
  342. totalLicenses: 21,
  343. nextPaymentDueAt,
  344. nextPaymentDueDate,
  345. currency: 'USD',
  346. state: 'active',
  347. trialEndsAtFormatted: null,
  348. trial_ends_at: null,
  349. activeCoupons: [],
  350. account: {
  351. email: 'fake@example.com',
  352. created_at: '2024-12-31T09:40:27.000Z',
  353. has_canceled_subscription: {
  354. _: 'false',
  355. $: {
  356. type: 'boolean',
  357. },
  358. },
  359. has_past_due_invoice: {
  360. _: 'false',
  361. $: {
  362. type: 'boolean',
  363. },
  364. },
  365. },
  366. displayPrice: '$2967.00',
  367. currentPlanDisplayPrice: '$2709.00',
  368. pendingAdditionalLicenses: 13,
  369. pendingTotalLicenses: 23,
  370. },
  371. pendingPlan: {
  372. planCode: 'group_collaborator_10_enterprise',
  373. name: 'Overleaf Standard (Collaborator) - Group Account (10 licenses) - Enterprise',
  374. hideFromUsers: true,
  375. price_in_cents: 129000,
  376. annual: true,
  377. groupPlan: true,
  378. membersLimit: 10,
  379. membersLimitAddOn: 'additional-license',
  380. },
  381. }
  382. export const trialSubscription: RecurlySubscription = {
  383. manager_ids: ['abc123'],
  384. member_ids: [],
  385. invited_emails: [],
  386. groupPlan: false,
  387. membersLimit: 0,
  388. _id: 'def456',
  389. admin_id: 'abc123',
  390. teamInvites: [],
  391. planCode: 'paid-personal_free_trial_7_days',
  392. recurlySubscription_id: 'ghi789',
  393. plan: {
  394. planCode: 'paid-personal_free_trial_7_days',
  395. name: 'Personal',
  396. price_in_cents: 1500,
  397. featureDescription: [],
  398. hideFromUsers: true,
  399. },
  400. recurly: {
  401. tax: 0,
  402. taxRate: 0,
  403. billingDetailsLink: '/user/subscription/recurly/billing-details',
  404. accountManagementLink: '/user/subscription/recurly/account-management',
  405. additionalLicenses: 0,
  406. totalLicenses: 0,
  407. nextPaymentDueAt: sevenDaysFromTodayFormatted,
  408. nextPaymentDueDate: sevenDaysFromTodayFormatted,
  409. currency: 'USD',
  410. state: 'active',
  411. trialEndsAtFormatted: sevenDaysFromTodayFormatted,
  412. trial_ends_at: new Date(sevenDaysFromToday).toString(),
  413. activeCoupons: [],
  414. account: {
  415. email: 'fake@example.com',
  416. created_at: '2024-12-31T09:40:27.000Z',
  417. has_canceled_subscription: {
  418. _: 'false',
  419. $: {
  420. type: 'boolean',
  421. },
  422. },
  423. has_past_due_invoice: {
  424. _: 'false',
  425. $: {
  426. type: 'boolean',
  427. },
  428. },
  429. },
  430. displayPrice: '$14.00',
  431. },
  432. }
  433. export const customSubscription: CustomSubscription = {
  434. manager_ids: ['abc123'],
  435. member_ids: [],
  436. invited_emails: [],
  437. groupPlan: false,
  438. membersLimit: 0,
  439. _id: 'def456',
  440. admin_id: 'abc123',
  441. teamInvites: [],
  442. planCode: 'collaborator-annual',
  443. recurlySubscription_id: 'ghi789',
  444. plan: {
  445. planCode: 'collaborator-annual',
  446. name: 'Standard (Collaborator) Annual',
  447. price_in_cents: 21900,
  448. annual: true,
  449. featureDescription: [],
  450. },
  451. customAccount: true,
  452. }
  453. export const trialCollaboratorSubscription: RecurlySubscription = {
  454. manager_ids: ['abc123'],
  455. member_ids: [],
  456. invited_emails: [],
  457. groupPlan: false,
  458. membersLimit: 0,
  459. _id: 'def456',
  460. admin_id: 'abc123',
  461. teamInvites: [],
  462. planCode: 'collaborator_free_trial_7_days',
  463. recurlySubscription_id: 'ghi789',
  464. plan: {
  465. planCode: 'collaborator_free_trial_7_days',
  466. name: 'Standard (Collaborator)',
  467. price_in_cents: 2300,
  468. featureDescription: [],
  469. hideFromUsers: true,
  470. },
  471. recurly: {
  472. tax: 0,
  473. taxRate: 0,
  474. billingDetailsLink: '/user/subscription/recurly/billing-details',
  475. accountManagementLink: '/user/subscription/recurly/account-management',
  476. additionalLicenses: 0,
  477. totalLicenses: 0,
  478. nextPaymentDueAt: sevenDaysFromTodayFormatted,
  479. nextPaymentDueDate: sevenDaysFromTodayFormatted,
  480. currency: 'USD',
  481. state: 'active',
  482. trialEndsAtFormatted: sevenDaysFromTodayFormatted,
  483. trial_ends_at: new Date(sevenDaysFromToday).toString(),
  484. activeCoupons: [],
  485. account: {
  486. email: 'foo@example.com',
  487. created_at: '2024-12-31T09:40:27.000Z',
  488. has_canceled_subscription: {
  489. _: 'false',
  490. $: {
  491. type: 'boolean',
  492. },
  493. },
  494. has_past_due_invoice: {
  495. _: 'false',
  496. $: {
  497. type: 'boolean',
  498. },
  499. },
  500. },
  501. displayPrice: '$21.00',
  502. },
  503. }
  504. export const monthlyActiveCollaborator: RecurlySubscription = {
  505. manager_ids: ['abc123'],
  506. member_ids: [],
  507. invited_emails: [],
  508. groupPlan: false,
  509. membersLimit: 0,
  510. _id: 'def456',
  511. admin_id: 'abc123',
  512. teamInvites: [],
  513. planCode: 'collaborator',
  514. recurlySubscription_id: 'ghi789',
  515. plan: {
  516. planCode: 'collaborator',
  517. name: 'Standard (Collaborator)',
  518. price_in_cents: 212300900,
  519. featureDescription: [],
  520. },
  521. recurly: {
  522. tax: 0,
  523. taxRate: 0,
  524. billingDetailsLink: '/user/subscription/recurly/billing-details',
  525. accountManagementLink: '/user/subscription/recurly/account-management',
  526. additionalLicenses: 0,
  527. totalLicenses: 0,
  528. nextPaymentDueAt,
  529. nextPaymentDueDate,
  530. currency: 'USD',
  531. state: 'active',
  532. trialEndsAtFormatted: null,
  533. trial_ends_at: null,
  534. activeCoupons: [],
  535. account: {
  536. email: 'foo@example.com',
  537. created_at: '2024-12-31T09:40:27.000Z',
  538. has_canceled_subscription: { _: 'false', $: { type: 'boolean' } },
  539. has_past_due_invoice: { _: 'false', $: { type: 'boolean' } },
  540. },
  541. displayPrice: '$21.00',
  542. },
  543. }