|
|
@@ -0,0 +1,99 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace App\Models;
|
|
|
+
|
|
|
+use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
+use Illuminate\Database\Eloquent\Model;
|
|
|
+use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @property int $id
|
|
|
+ * @property int $unit_id
|
|
|
+ * @property float $revenue_value
|
|
|
+ * @property int $contract_month_reference
|
|
|
+ * @property float $tbr_value
|
|
|
+ * @property int $fnm_bracket_id
|
|
|
+ * @property float $fnm_bracket_percentage
|
|
|
+ * @property float $fnm_bracket_value
|
|
|
+ * @property int $maintenance_bracket_id
|
|
|
+ * @property float $maintenance_bracket_percentage
|
|
|
+ * @property float $maintenance_bracket_value
|
|
|
+ * @property int $royalties_bracket_id
|
|
|
+ * @property float $royalties_bracket_percentage
|
|
|
+ * @property float $royalties_bracket_value
|
|
|
+ * @property float $fnm_effective_percentage
|
|
|
+ * @property float $fnm_effective_value
|
|
|
+ * @property float $royalties_effective_percentage
|
|
|
+ * @property float $royalties_effective_value
|
|
|
+ * @property float $maintenance_effective_percentage
|
|
|
+ * @property float $maintenance_effective_value
|
|
|
+ * @property float $bracket_subtotal
|
|
|
+ * @property float $subtotal
|
|
|
+ * @property float $final_value
|
|
|
+ * @property int $user_id
|
|
|
+ * @property string $royalties_applied_criteria
|
|
|
+ * @property bool $receivable_generated
|
|
|
+ * @property \Carbon\Carbon $created_at
|
|
|
+ * @property \Carbon\Carbon $updated_at
|
|
|
+ * @property-read \App\Models\Unit $unit
|
|
|
+ * @property-read \App\Models\FranchiseeFnmBracket $fnmBracket
|
|
|
+ * @property-read \App\Models\FranchiseeMaintenanceBracket $maintenanceBracket
|
|
|
+ * @property-read \App\Models\FranchiseeRoyaltiesBracket $royaltiesBracket
|
|
|
+ * @property-read \App\Models\User $user
|
|
|
+ */
|
|
|
+class TbrCalculation extends Model
|
|
|
+{
|
|
|
+ use HasFactory;
|
|
|
+
|
|
|
+ protected $table = 'tbr_calculations';
|
|
|
+
|
|
|
+ protected $guarded = ['id'];
|
|
|
+
|
|
|
+ protected $casts = [
|
|
|
+ 'revenue_value' => 'decimal:2',
|
|
|
+ 'tbr_value' => 'decimal:2',
|
|
|
+ 'fnm_bracket_percentage' => 'decimal:4',
|
|
|
+ 'fnm_bracket_value' => 'decimal:2',
|
|
|
+ 'maintenance_bracket_percentage' => 'decimal:4',
|
|
|
+ 'maintenance_bracket_value' => 'decimal:2',
|
|
|
+ 'royalties_bracket_percentage' => 'decimal:4',
|
|
|
+ 'royalties_bracket_value' => 'decimal:2',
|
|
|
+ 'fnm_effective_percentage' => 'decimal:4',
|
|
|
+ 'fnm_effective_value' => 'decimal:2',
|
|
|
+ 'royalties_effective_percentage' => 'decimal:4',
|
|
|
+ 'royalties_effective_value' => 'decimal:2',
|
|
|
+ 'maintenance_effective_percentage' => 'decimal:4',
|
|
|
+ 'maintenance_effective_value' => 'decimal:2',
|
|
|
+ 'bracket_subtotal' => 'decimal:2',
|
|
|
+ 'subtotal' => 'decimal:2',
|
|
|
+ 'final_value' => 'decimal:2',
|
|
|
+ 'receivable_generated' => 'boolean',
|
|
|
+ 'created_at' => 'datetime',
|
|
|
+ 'updated_at' => 'datetime',
|
|
|
+ ];
|
|
|
+
|
|
|
+ public function unit(): BelongsTo
|
|
|
+ {
|
|
|
+ return $this->belongsTo(Unit::class, 'unit_id');
|
|
|
+ }
|
|
|
+
|
|
|
+ public function fnmBracket(): BelongsTo
|
|
|
+ {
|
|
|
+ return $this->belongsTo(FranchiseeFnmBracket::class, 'fnm_bracket_id');
|
|
|
+ }
|
|
|
+
|
|
|
+ public function maintenanceBracket(): BelongsTo
|
|
|
+ {
|
|
|
+ return $this->belongsTo(FranchiseeMaintenanceBracket::class, 'maintenance_bracket_id');
|
|
|
+ }
|
|
|
+
|
|
|
+ public function royaltiesBracket(): BelongsTo
|
|
|
+ {
|
|
|
+ return $this->belongsTo(FranchiseeRoyaltiesBracket::class, 'royalties_bracket_id');
|
|
|
+ }
|
|
|
+
|
|
|
+ public function user(): BelongsTo
|
|
|
+ {
|
|
|
+ return $this->belongsTo(User::class, 'user_id');
|
|
|
+ }
|
|
|
+}
|