This commit is contained in:
meghamalore
2024-07-01 11:07:34 +05:30
4 changed files with 138 additions and 66 deletions

View File

@@ -1171,37 +1171,62 @@ class ManageUserProductController extends Controller
public function updateStatusAlternative(Request $request)
{
// dd($request->all());
$status = $request->status;
$id = $request->id;
$custom_id = $request->custom_id;
$count = MonthlyUpdateAlternativeInvestmentFund::where('custom_id', $custom_id)->get()->count();
if($count > 1)
if(MonthlyUpdateAlternativeInvestmentFund::where('custom_id', $request->custom_id)->where('status',true)->get()->count() >= 1)
{
if ($status == "1") {
$update = MonthlyUpdateAlternativeInvestmentFund::where('id', $id)->update([
'status' => '0'
]);
} else {
$update = MonthlyUpdateAlternativeInvestmentFund::where('id', $id)->update([
"status" => "1"
]);
}
return response()->json(
[
"status" => 'success',
"code" => 200,
"message" => "Status Changed"
]
);
if($request->status == '1')
{
$other = MonthlyUpdateAlternativeInvestmentFund::where(['custom_id'=> $request->custom_id, 'status'=>false])->whereNotIn('id', [$request->id])->orderByDesc('created_at')->limit(1)->first();
if($other)
{
$inactiveAll = MonthlyUpdateAlternativeInvestmentFund::where('custom_id', $request->custom_id)->update(['status'=>false]);
if($inactiveAll)
{
MonthlyUpdateAlternativeInvestmentFund::where('id', $other->id)->update(['status'=>true]);
}
}
}else{
$falseAll = MonthlyUpdateAlternativeInvestmentFund::where('custom_id', $request->custom_id)->update(['status'=>false]);
if($falseAll)
{
MonthlyUpdateAlternativeInvestmentFund::where(['id'=>$request->id,'custom_id'=>$request->custom_id])->update(['status'=>true]);
}
}
return response(['status' => 200, 'message'=>'Product status changed successfully']);
}
return response(['status' => 400, 'message'=>'Status not changed, Atleast one should be active']);
// old running code
// dd($request->all());
return response()->json(
[
"status" => 400,
"message" => "Status not changed, Atleast one should be active",
]
);
// $status = $request->status;
// $id = $request->id;
// $custom_id = $request->custom_id;
// $count = MonthlyUpdateAlternativeInvestmentFund::where('custom_id', $custom_id)->get()->count();
// if($count > 1)
// {
// if ($status == "1") {
// $update = MonthlyUpdateAlternativeInvestmentFund::where('id', $id)->update([
// 'status' => '0'
// ]);
// } else {
// $update = MonthlyUpdateAlternativeInvestmentFund::where('id', $id)->update([
// "status" => "1"
// ]);
// }
// return response()->json(
// [
// "status" => 'success',
// "code" => 200,
// "message" => "Status Changed"
// ]
// );
// }
// // dd($request->all());
// return response()->json(
// [
// "status" => 400,
// "message" => "Status not changed, Atleast one should be active",
// ]
// );
}
public function updateIndianFinancialStatus(Request $request)
@@ -1222,17 +1247,40 @@ class ManageUserProductController extends Controller
}
public function updateFractionalRealEstateStatus(Request $request)
{
if(MonthlyUpdateFractionalRealEstate::where('custom_id', $request->custom_id)->get()->count() > 1)
if(MonthlyUpdateFractionalRealEstate::where('custom_id', $request->custom_id)->where('status',true)->get()->count() >= 1)
{
$data = MonthlyUpdateFractionalRealEstate::where('id', $request->id)->first();
if ($data) {
if ($request->status == '1') {
$data->status = '0';
} else {
$data->status = '1';
// $data = MonthlyUpdateFractionalRealEstate::where('custom_id', $request->custom_id)->get();
// foreach($data as $row)
// {
if($request->status == '1')
{
$other = MonthlyUpdateFractionalRealEstate::where(['custom_id'=> $request->custom_id, 'status'=>false])->whereNotIn('id', [$request->id])->orderByDesc('created_at')->limit(1)->first();
if($other)
{
$inactiveAll = MonthlyUpdateFractionalRealEstate::where('custom_id', $request->custom_id)->update(['status'=>false]);
if($inactiveAll)
{
MonthlyUpdateFractionalRealEstate::where('id', $other->id)->update(['status'=>true]);
}
}
}else{
$falseAll = MonthlyUpdateFractionalRealEstate::where('custom_id', $request->custom_id)->update(['status'=>false]);
if($falseAll)
{
MonthlyUpdateFractionalRealEstate::where(['id'=>$request->id,'custom_id'=>$request->custom_id])->update(['status'=>true]);
}
}
$data->save();
}
// }
// $data = MonthlyUpdateFractionalRealEstate::where('id', $request->id)->first();
// if ($data) {
// if ($request->status == '1') {
// $data->status = '0';
// } else {
// $data->status = '1';
// }
// $data->save();
// }
return response(['status' => 200, 'message'=>'Product status changed successfully']);
}

View File

@@ -24,6 +24,7 @@ class HandpickedInvestmentController extends Controller
}
$geographicFocus = request()->geographicFocus ?? null;
$products = $this->filterData(request()->search ?? '', $urlCategories, $assetType, $geographicFocus);
// dd($products->toArray());
$type = FractionalRealEstate::select('asset_type')->distinct()->get();
$categories = Product::query()
->join('categories', 'products.categories_id', 'categories.id')
@@ -87,17 +88,24 @@ class HandpickedInvestmentController extends Controller
];
$products = Product::query()
->select(DB::raw('products.id, products.description, products.categories_id as category_id, coalesce(fre.property_name_and_location,aif.fund_name,re.property_name,funds.fund_name) as product_name'), DB::raw('coalesce(companies.company_logo) as company_logo'), DB::raw('coalesce(fre.slug,aif.slug,re.slug, funds.slug) as slug'), DB::raw('coalesce(fre.geographic_focus,aif.geographic_focus,re.geographic_focus, funds.geographic_focus) as geographic_focus'), DB::raw('coalesce(aif.minimum_investment,fre.minimum_investment,funds.minimum_investment,re.total_price) as minimum_investment'),
->select(DB::raw('products.id, products.description, products.categories_id as category_id, coalesce(fre.property_name_and_location,aif.fund_name,re.property_name,funds.fund_name) as product_name'),
DB::raw('coalesce(companies.company_logo) as company_logo'), DB::raw('coalesce(fre.slug,aif.slug,re.slug, funds.slug) as slug'), DB::raw('coalesce(fre.geographic_focus,aif.geographic_focus,re.geographic_focus, funds.geographic_focus) as geographic_focus'), DB::raw('coalesce(aif.minimum_investment,fre.minimum_investment,funds.minimum_investment,re.total_price) as minimum_investment'),
// DB::raw('coalesce(aif.description,fre.property_description,re.remarks,funds.fund_description) as description'),
// DB::raw('coalesce(fre.property_description,products.description) as description'),
// 'products.description',
DB::raw('coalesce(categories.category_name) as category_name'))
->leftJoin('fractional_real_estates as fre', 'products.id', 'fre.products_id')
->leftJoin('alternative_investment_funds as aif', 'products.id', 'aif.products_id')
->leftJoin('companies', 'fre.companies_id', 'companies.id')
// ->leftJoin('companies', 'fre.companies_id', 'companies.id')
->leftJoin('real_estates as re', 'products.id', 're.products_id')
->leftJoin('categories', 'products.categories_id', 'categories.id')
->leftJoin('funds', 'products.id', 'funds.products_id')
->leftJoin('categories', 'products.categories_id', 'categories.id')
->leftJoin('companies',function($query){
$query->on('fre.companies_id', 'companies.id')
->orOn('aif.companies_id', 'companies.id')
->orOn('funds.platform_partner', 'companies.id')
->orOn('re.platform_partner', 'companies.id');
})
->when($assetType == 'financial-assets', function ($query) use ($faCategoriesArr, $geographicFocus) {
$query->whereIn('products.categories_id', $faCategoriesArr);
$query->when($geographicFocus, function ($query) use ($geographicFocus) {

View File

@@ -7,12 +7,13 @@ use Illuminate\Support\Facades\Validator;
use Maatwebsite\Excel\Concerns\ToCollection;
use Maatwebsite\Excel\Concerns\WithHeadingRow;
use App\Models\MonthlyUpdateAlternativeInvestmentFund;
use Carbon\Carbon;
class ImportMontlyUpdateAlternativeInvestmentFund implements ToCollection, WithHeadingRow
{
/**
* @param Collection $collection
*/
* @param Collection $collection
*/
public function rules(): array
{
// return null;
@@ -44,27 +45,32 @@ class ImportMontlyUpdateAlternativeInvestmentFund implements ToCollection, With
Validator::make($rows->toArray(), $this->rules(), $this->customValidationMessages($rows))->validate();
foreach ($rows as $row) {
if($row['commitment_amount'] != null && $row['contribution_amount'] != null && $row['contribution_called_amount'] != null && $row['contribution_uncalled_amount'] != null)
{
MonthlyUpdateAlternativeInvestmentFund::create([
'custom_id' => $row['custom_id'] ?? null,
'commitment_amount' => $row['commitment_amount'] ?? 0,
'contribution_amount' => $row['contribution_amount'] ?? 0,
'contribution_called_amount' => $row['contribution_called_amount'] ?? 0,
'contribution_uncalled_amount' => $row['contribution_uncalled_amount'] ?? 0,
'date_of_initial_contribution' => getConvertedDate($row['date_of_initial_contribution']) ?? 0,
'face_value_nav_per_unit' => $row['face_valuenav_per_unit'] ?? 0,
'principal_capital_repaid' => $row['principal_capital_repaid'] ?? 0,
'gross_income' => $row['gross_income'] ?? 0,
'total_fees_paid' => $row['total_fees_paid_set_up_management_operating'] ?? 0,
'net_income' => $row['net_income'] ?? 0,
'no_of_units_alloted' => $row['no_of_units_alloted'] ?? 0,
'no_of_units_redeemed' => $row['no_of_units_redeemed'] ?? 0,
'current_valuation' => $row['current_valuation'] ?? 0,
'current_nav' => $row['current_nav'] ?? 0,
'no_of_units_held' => $row['no_of_units_held'] ?? 0,
]);
}
if ($row['commitment_amount'] != null && $row['contribution_amount'] != null && $row['contribution_called_amount'] != null && $row['contribution_uncalled_amount'] != null) {
$latestId = MonthlyUpdateAlternativeInvestmentFund::insertGetId([
'custom_id' => $row['custom_id'] ?? null,
'commitment_amount' => $row['commitment_amount'] ?? 0,
'contribution_amount' => $row['contribution_amount'] ?? 0,
'contribution_called_amount' => $row['contribution_called_amount'] ?? 0,
'contribution_uncalled_amount' => $row['contribution_uncalled_amount'] ?? 0,
'date_of_initial_contribution' => getConvertedDate($row['date_of_initial_contribution']) ?? 0,
'face_value_nav_per_unit' => $row['face_valuenav_per_unit'] ?? 0,
'principal_capital_repaid' => $row['principal_capital_repaid'] ?? 0,
'gross_income' => $row['gross_income'] ?? 0,
'total_fees_paid' => $row['total_fees_paid_set_up_management_operating'] ?? 0,
'net_income' => $row['net_income'] ?? 0,
'no_of_units_alloted' => $row['no_of_units_alloted'] ?? 0,
'no_of_units_redeemed' => $row['no_of_units_redeemed'] ?? 0,
'current_valuation' => $row['current_valuation'] ?? 0,
'current_nav' => $row['current_nav'] ?? 0,
'no_of_units_held' => $row['no_of_units_held'] ?? 0,
'created_at' => Carbon::now(),
'updated_at' => Carbon::now(),
]);
$falseAll = MonthlyUpdateAlternativeInvestmentFund::where('custom_id', $row['custom_id'])->update(['status' => false]);
if ($falseAll) {
MonthlyUpdateAlternativeInvestmentFund::where(['id' => $latestId, 'custom_id' => $row['custom_id']])->update(['status' => true]);
}
}
}
}
}

View File

@@ -7,6 +7,7 @@ use Illuminate\Support\Facades\Validator;
use Maatwebsite\Excel\Concerns\ToCollection;
use Maatwebsite\Excel\Concerns\WithHeadingRow;
use App\Models\MonthlyUpdateFractionalRealEstate;
use Carbon\Carbon;
class ImportMontlyUpdateFractionalRealEstate implements ToCollection, WithHeadingRow
{
@@ -46,9 +47,10 @@ class ImportMontlyUpdateFractionalRealEstate implements ToCollection, WithHeadin
foreach ($rows as $row) {
// dd($row);
if($row['investment_value'] != null && $row['total_net_interest'] != null && $row['total_gross_interest'] != null && $row['total_value_of_the_property'] != null)
{
MonthlyUpdateFractionalRealEstate::create([
$latestId = MonthlyUpdateFractionalRealEstate::insertGetId([
'custom_id' => $row['custom_id'],
'total_value_of_the_property' => $row['total_value_of_the_property'] ?? 0,
'investment_value' => $row['investment_value'] ?? 0,
@@ -56,10 +58,18 @@ class ImportMontlyUpdateFractionalRealEstate implements ToCollection, WithHeadin
'total_gross_interest' => $row['total_gross_interest'] ?? 0,
'tds' => $row['tds'] ?? 0,
'total_net_interest' => $row['total_net_interest'] ?? 0,
'gross_entry_yield' => $row['gross_entry_yield'] ?? 0,
'target_return' => $row['target_return'] ?? 0,
'gross_entry_yield_in_pct' => $row['gross_entry_yield'] ?? 0,
'target_return_in_pct' => $row['target_return'] ?? 0,
'absolute_return_till_date' => $row['absolute_return_till_date'],
'created_at' => Carbon::now(),
'updated_at' => Carbon::now(),
]);
$falseAll = MonthlyUpdateFractionalRealEstate::where('custom_id', $row['custom_id'])->update(['status'=>false]);
if($falseAll)
{
MonthlyUpdateFractionalRealEstate::where(['id'=>$latestId,'custom_id'=>$row['custom_id']])->update(['status'=>true]);
}
}
}
}