154 lines
4.1 KiB
PHP
154 lines
4.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class MonthlyUpdatePeerToPeerLending extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = ['custom_id','total_investment','principal_redemption','interest_paidout','net_principal_investment','capitalised_interest','accrued_interest','portfolio_value','absolute_return_in_rs','absolute_return_in_pct','annualised_return','total_value','investment_amount','all_time_amount_invested','interest_accrued','net_interest_redemption','escrow_balance','average_roi','all_time_investment_added','total_active_investment','net_expected_value_at_maturity','net_asset_value','amount_withdrawn','statement_reports','status'];
|
|
|
|
// const path = 'https://staging.freeu.in/api/get-statement-report/';
|
|
|
|
public function getStatementReportsAttribute($value)
|
|
{
|
|
$arr = [];
|
|
if($value){
|
|
|
|
foreach(json_decode($value) as $data){
|
|
$val = imagePath('api/get-statement-report/') . $data;
|
|
array_push($arr,$val);
|
|
}
|
|
}
|
|
return $arr ;
|
|
}
|
|
|
|
//Liquiloans - Accessor
|
|
public function getTotalInvestmentAttribute($value)
|
|
{
|
|
return $this->IND_money_format($value) ;
|
|
}
|
|
|
|
public function getAccruedInterestAttribute($value)
|
|
{
|
|
return $this->IND_money_format($value) ;
|
|
}
|
|
|
|
public function getPortfolioValueAttribute($value)
|
|
{
|
|
return $this->IND_money_format($value) ;
|
|
}
|
|
|
|
public function getNetPrincipalInvestmentAttribute($value)
|
|
{
|
|
return $this->IND_money_format($value) ;
|
|
}
|
|
|
|
public function getAnnualisedReturnAttribute($value)
|
|
{
|
|
return $this->IND_money_format($value) ;
|
|
}
|
|
|
|
//Faircent - Accessor
|
|
public function getTotalValueAttribute($value)
|
|
{
|
|
return $this->IND_money_format($value) ;
|
|
}
|
|
|
|
public function getInvestmentAmountAttribute($value)
|
|
{
|
|
return $this->IND_money_format($value) ;
|
|
}
|
|
|
|
public function getAllTimeAmountInvestedAttribute($value)
|
|
{
|
|
return $this->IND_money_format($value) ;
|
|
}
|
|
|
|
public function getInterestAccruedAttribute($value)
|
|
{
|
|
return $this->IND_money_format($value) ;
|
|
}
|
|
|
|
public function getPrincipalRedemptionAttribute($value)
|
|
{
|
|
return $this->IND_money_format($value) ;
|
|
}
|
|
|
|
public function getNetInterestRedemptionAttribute($value)
|
|
{
|
|
return $this->IND_money_format($value) ;
|
|
}
|
|
|
|
public function getEscrowBalanceAttribute($value)
|
|
{
|
|
return $this->IND_money_format($value) ;
|
|
}
|
|
|
|
//Finance Peer - Accessor
|
|
|
|
public function getAllTimeInvestmentAddedAttribute($value)
|
|
{
|
|
return $this->IND_money_format($value) ;
|
|
}
|
|
|
|
public function getTotalActiveInvestmentAttribute($value)
|
|
{
|
|
return $this->IND_money_format($value) ;
|
|
}
|
|
|
|
public function getNextExpectedValueAtMaturityAttribute($value)
|
|
{
|
|
return $this->IND_money_format($value) ;
|
|
}
|
|
|
|
public function getNetAssetValueAttribute($value)
|
|
{
|
|
return $this->IND_money_format($value) ;
|
|
}
|
|
|
|
public function getAmountWithdrawnAttribute($value)
|
|
{
|
|
return $this->IND_money_format($value) ;
|
|
}
|
|
|
|
public function getInterestPaidoutAttribute($value)
|
|
{
|
|
return $this->IND_money_format($value) ;
|
|
}
|
|
|
|
public function getAbsoluteReturnInRsAttribute($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;
|
|
}
|
|
}
|