subscriptions.ts 14 KB

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