70 lines
2.0 KiB
PHP
70 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class MonthlyUpdateIndianFinancialAssets extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = ['custom_id','investment_date','amount_invested','total_gross_repaid_amount','tenure_in_days','principal_payment_frequency','interest_payment_frequency','next_repayment_due_date','maturity_date','next_repayment_amount','expected_irr','repayment_schedule'];
|
|
|
|
// const path = 'https://jerichoalternatives.in/api/get-statement-report/';
|
|
|
|
public function getRepaymentScheduleAttribute($value)
|
|
{
|
|
if($value){
|
|
$arr = [];
|
|
foreach(json_decode($value) as $data){
|
|
$val = imagePath('api/get-statement-report/') . $data;
|
|
array_push($arr,$val);
|
|
}
|
|
return $arr ;
|
|
}
|
|
}
|
|
|
|
public function getAmountInvestedAttribute($value){
|
|
return '₹ ' . $this->IND_money_format($value);
|
|
}
|
|
|
|
public function getTotalGrossRepaidAmountAttribute($value){
|
|
return '₹ ' . $this->IND_money_format($value);
|
|
}
|
|
|
|
public function getNextRepaymentAmountAttribute($value){
|
|
return '₹ ' . $this->IND_money_format($value);
|
|
}
|
|
|
|
public function getExpectedIrrAttribute($value){
|
|
return $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;
|
|
}
|
|
}
|