TbrCalculation.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Factories\HasFactory;
  4. use Illuminate\Database\Eloquent\Model;
  5. use Illuminate\Database\Eloquent\Relations\BelongsTo;
  6. /**
  7. * @property int $id
  8. * @property int $unit_id
  9. * @property float $revenue_value
  10. * @property int $contract_month_reference
  11. * @property float $tbr_value
  12. * @property int $fnm_bracket_id
  13. * @property float $fnm_bracket_percentage
  14. * @property float $fnm_bracket_value
  15. * @property int $maintenance_bracket_id
  16. * @property float $maintenance_bracket_percentage
  17. * @property float $maintenance_bracket_value
  18. * @property int $royalties_bracket_id
  19. * @property float $royalties_bracket_percentage
  20. * @property float $royalties_bracket_value
  21. * @property float $fnm_effective_percentage
  22. * @property float $fnm_effective_value
  23. * @property float $royalties_effective_percentage
  24. * @property float $royalties_effective_value
  25. * @property float $maintenance_effective_percentage
  26. * @property float $maintenance_effective_value
  27. * @property float $bracket_subtotal
  28. * @property float $subtotal
  29. * @property float $final_value
  30. * @property int $user_id
  31. * @property string $royalties_applied_criteria
  32. * @property bool $receivable_generated
  33. * @property \Carbon\Carbon $created_at
  34. * @property \Carbon\Carbon $updated_at
  35. * @property-read \App\Models\Unit $unit
  36. * @property-read \App\Models\FranchiseeFnmBracket $fnmBracket
  37. * @property-read \App\Models\FranchiseeMaintenanceBracket $maintenanceBracket
  38. * @property-read \App\Models\FranchiseeRoyaltiesBracket $royaltiesBracket
  39. * @property-read \App\Models\User $user
  40. */
  41. class TbrCalculation extends Model
  42. {
  43. use HasFactory;
  44. protected $table = 'tbr_calculations';
  45. protected $guarded = ['id'];
  46. protected $casts = [
  47. 'revenue_value' => 'decimal:2',
  48. 'tbr_value' => 'decimal:2',
  49. 'fnm_bracket_percentage' => 'decimal:4',
  50. 'fnm_bracket_value' => 'decimal:2',
  51. 'maintenance_bracket_percentage' => 'decimal:4',
  52. 'maintenance_bracket_value' => 'decimal:2',
  53. 'royalties_bracket_percentage' => 'decimal:4',
  54. 'royalties_bracket_value' => 'decimal:2',
  55. 'fnm_effective_percentage' => 'decimal:4',
  56. 'fnm_effective_value' => 'decimal:2',
  57. 'royalties_effective_percentage' => 'decimal:4',
  58. 'royalties_effective_value' => 'decimal:2',
  59. 'maintenance_effective_percentage' => 'decimal:4',
  60. 'maintenance_effective_value' => 'decimal:2',
  61. 'bracket_subtotal' => 'decimal:2',
  62. 'subtotal' => 'decimal:2',
  63. 'final_value' => 'decimal:2',
  64. 'receivable_generated' => 'boolean',
  65. 'created_at' => 'datetime',
  66. 'updated_at' => 'datetime',
  67. ];
  68. public function unit(): BelongsTo
  69. {
  70. return $this->belongsTo(Unit::class, 'unit_id');
  71. }
  72. public function fnmBracket(): BelongsTo
  73. {
  74. return $this->belongsTo(FranchiseeFnmBracket::class, 'fnm_bracket_id');
  75. }
  76. public function maintenanceBracket(): BelongsTo
  77. {
  78. return $this->belongsTo(FranchiseeMaintenanceBracket::class, 'maintenance_bracket_id');
  79. }
  80. public function royaltiesBracket(): BelongsTo
  81. {
  82. return $this->belongsTo(FranchiseeRoyaltiesBracket::class, 'royalties_bracket_id');
  83. }
  84. public function user(): BelongsTo
  85. {
  86. return $this->belongsTo(User::class, 'user_id');
  87. }
  88. }