fixed monthly update active or inactive
This commit is contained in:
@@ -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']);
|
||||
}
|
||||
|
||||
@@ -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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user