subscriptions.ts 16 KB

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