67 lines
1.7 KiB
PHP
67 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class MonthlyUpdateMasterCommission extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $table = 'monthly_update_commissions';
|
|
|
|
protected $fillable = ['monthly_id', 'total_investment_or_commitment_amount', 'applicable_rate', 'type_of_commission', 'gross_commissioned_earned_inr', 'gst', 'tds', 'net_commission_received'];
|
|
|
|
public function monthlyUpdate()
|
|
{
|
|
return $this->belongsTo(MonthlyUpdateMaster::class, 'monthly_id');
|
|
}
|
|
|
|
public function getTotalInvestmentOrCommitmentAmountAttribute($value)
|
|
{
|
|
return $this->IND_money_format($value);
|
|
}
|
|
|
|
public function getGrossCommissionedEarnedInrAttribute($value)
|
|
{
|
|
return $this->IND_money_format($value);
|
|
}
|
|
|
|
public function getNetCommissionReceivedAttribute($value)
|
|
{
|
|
return $this->IND_money_format($value);
|
|
}
|
|
|
|
function IND_money_format($number)
|
|
{
|
|
$decimal = (string)($number - floor($number));
|
|
$money = floor($number);
|
|
$length = strlen($money);
|
|
$delimiter = '';
|
|
$money = strrev($money);
|
|
|
|
for ($i = 0; $i < $length; $i++) {
|
|
if (($i == 3 || ($i > 3 && ($i - 1) % 2 == 0)) && $i != $length) {
|
|
$delimiter .= ',';
|
|
}
|
|
$delimiter .= $money[$i];
|
|
}
|
|
|
|
$result = strrev($delimiter);
|
|
$decimal = preg_replace("/0\./i", ".", $decimal);
|
|
$decimal = substr($decimal, 0, 3);
|
|
|
|
if ($decimal != '0') {
|
|
$result = $result . $decimal;
|
|
}
|
|
|
|
return '₹ ' . $result;
|
|
}
|
|
|
|
public function products()
|
|
{
|
|
return $this->belongsTo(Product::class, 'products_id');
|
|
}
|
|
}
|