billingMenuBuilder.ts 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. import AbstractMenuBuilder from '~/services/layout/menuBuilder/abstractMenuBuilder'
  2. import type { MenuGroup, MenuItem, MenuItems } from '~/types/layout'
  3. import { MENU_LINK_TYPE } from '~/types/enum/layout'
  4. /**
  5. * Menu Facturation
  6. */
  7. export default class BillingMenuBuilder extends AbstractMenuBuilder {
  8. static override readonly menuName = 'Billing'
  9. /**
  10. * Construit le menu Facturation ou null si aucune page accessible
  11. */
  12. build(): MenuItem | MenuGroup | null {
  13. const children: MenuItems = []
  14. if (this.ability.can('display', 'billing_product_page')) {
  15. children.push(
  16. this.createItem(
  17. 'billing_product',
  18. { name: 'fas fa-cube' },
  19. '/intangibles/list/',
  20. MENU_LINK_TYPE.V1,
  21. ),
  22. )
  23. }
  24. if (this.ability.can('display', 'billing_products_by_student_page')) {
  25. children.push(
  26. this.createItem(
  27. 'billing_products_by_student',
  28. { name: 'fas fa-cubes' },
  29. '/access_intangibles/list/',
  30. MENU_LINK_TYPE.V1,
  31. ),
  32. )
  33. }
  34. if (this.ability.can('display', 'billing_edition_page')) {
  35. children.push(
  36. this.createItem(
  37. 'billing_edition',
  38. { name: 'fas fa-copy' },
  39. '/billing_edition',
  40. MENU_LINK_TYPE.V1,
  41. ),
  42. )
  43. }
  44. if (this.ability.can('display', 'billing_accounting_page')) {
  45. children.push(
  46. this.createItem(
  47. 'billing_accounting',
  48. { name: 'fas fa-file-alt' },
  49. '/bill_accountings/list/',
  50. MENU_LINK_TYPE.V1,
  51. ),
  52. )
  53. }
  54. if (this.ability.can('display', 'billing_payment_list_page')) {
  55. children.push(
  56. this.createItem(
  57. 'billing_payment_list',
  58. { name: 'fas fa-credit-card' },
  59. '/bill_payments_list/list/',
  60. MENU_LINK_TYPE.V1,
  61. ),
  62. )
  63. }
  64. if (this.ability.can('display', 'pes_page')) {
  65. children.push(
  66. this.createItem(
  67. 'pes_export',
  68. { name: 'fas fa-align-justify' },
  69. '/pes/list/',
  70. MENU_LINK_TYPE.V1,
  71. ),
  72. )
  73. }
  74. if (this.ability.can('display', 'berger_levrault_page')) {
  75. children.push(
  76. this.createItem(
  77. 'berger_levrault_export',
  78. { name: 'fas fa-align-justify' },
  79. '/berger_levraults/list/',
  80. MENU_LINK_TYPE.V1,
  81. ),
  82. )
  83. }
  84. if (this.ability.can('display', 'jvs_page')) {
  85. children.push(
  86. this.createItem(
  87. 'jvs_export',
  88. { name: 'fas fa-align-justify' },
  89. '/jvs/list/',
  90. MENU_LINK_TYPE.V1,
  91. ),
  92. )
  93. }
  94. if (this.ability.can('display', 'afi_page')) {
  95. children.push(
  96. this.createItem(
  97. 'afi_export',
  98. { name: 'fas fa-align-justify' },
  99. '/afis/list/',
  100. MENU_LINK_TYPE.V1,
  101. ),
  102. )
  103. }
  104. if (children.length > 1) {
  105. // Plusieurs éléments, on retourne un groupe
  106. return this.createGroup('billing', { name: 'fas fa-euro-sign' }, children)
  107. } else if (children.length === 1) {
  108. // Un seul élément, on retourne cet élément seul
  109. return children[0]
  110. }
  111. return null
  112. }
  113. }