From f2adb3c2ec675273e6252aa6127cda4105563d03 Mon Sep 17 00:00:00 2001 From: Ritikesh yadav Date: Tue, 7 May 2024 17:26:06 +0530 Subject: [PATCH] fixing fractional bid issue --- .../Controllers/Admin/OverviewController.php | 11 ++++++--- .../MarketplaceFractionalRealEstateSeller.php | 23 ++++++++++--------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/app/Http/Controllers/Admin/OverviewController.php b/app/Http/Controllers/Admin/OverviewController.php index 1e1fa27..1d5d6cd 100644 --- a/app/Http/Controllers/Admin/OverviewController.php +++ b/app/Http/Controllers/Admin/OverviewController.php @@ -233,17 +233,22 @@ class OverviewController extends Controller $getFREData = MarketplaceFractionalRealEstateSeller::where('id',$marketPlaceId)->first(); $freValue = (int)$getFREData->current_market_value_of_the_property; $nowValue = $freValue - $getBuyingPurchaseValue; - // $nowValue = -10; - // dd($freValue,' - ',$getBuyingPurchaseValue,' = ',$nowValue); - // dd($nowValue < 0 ? 'negative '.$nowValue : 'positive '.$nowValue); + + $percentage = ($freValue - $getBuyingPurchaseValue) / $freValue * 100; + + $expectedSellingPrice = (int)$getFREData->expected_selling_price; + $updateExpectedSellingPrice = $expectedSellingPrice * ($percentage / 100); + // dd($percentage,$updateExpectedSellingPrice); if($nowValue <= 0) { $updatePrice = MarketplaceFractionalRealEstateSeller::where('id',$marketPlaceId)->update([ 'current_market_value_of_the_property' => 0, + 'expected_selling_price' => 0, ]); }else if($nowValue > 0){ $updatePrice = MarketplaceFractionalRealEstateSeller::where('id',$marketPlaceId)->update([ 'current_market_value_of_the_property' => $nowValue, + 'expected_selling_price' => $updateExpectedSellingPrice, ]); } // else{ diff --git a/app/Models/MarketplaceFractionalRealEstateSeller.php b/app/Models/MarketplaceFractionalRealEstateSeller.php index 28ac5ae..029ba39 100644 --- a/app/Models/MarketplaceFractionalRealEstateSeller.php +++ b/app/Models/MarketplaceFractionalRealEstateSeller.php @@ -61,18 +61,19 @@ class MarketplaceFractionalRealEstateSeller extends Model public function getSoldStatusAttribute($id) { - return MarketplaceBuyerForm::where('associated_id', $id)->where('status', 'Sold')->exists() ? 'SOLD' : 'OPEN'; - $buyerData = MarketplaceBuyerForm::where('associated_id', $id)->where('status', 'Sold')->get(); - $totalSellUnits = 0; - $buyerData->each(function($data) use($totalSellUnits){ - return $totalSellUnits += (int)$data->no_of_units_you_wish_to_buy; - }); - if(MarketplaceFractionalRealEstateSeller::where('id',$buyerData->associated_id)->exists()) + // return MarketplaceBuyerForm::where('associated_id', $id)->where('status', 'Sold')->exists() ? 'SOLD' : 'OPEN'; + // dd($id); + // $buyerData = MarketplaceBuyerForm::where('associated_id', $this->id)->where('status', 'Sold')->get(); + // $totalSellUnits = 0; + // $buyerData->each(function($data) use($totalSellUnits){ + // return $totalSellUnits += (int)$data->no_of_units_you_wish_to_buy; + // }); + if(MarketplaceFractionalRealEstateSeller::where('id',$id)->exists()) { - $getAIFData = MarketplaceFractionalRealEstateSeller::where('id',$buyerData->associated_id)->first(); - $aifData = (int)$getAIFData->no_of_units_you_wish_to_sell; - $remainUnits = $aifData - $totalSellUnits; - if($remainUnits < 0) + $getFREData = MarketplaceFractionalRealEstateSeller::where('id',$id)->first(); + // $aifData = (int)$getFREData->no_of_units_you_wish_to_sell; + // $remainUnits = $aifData - $totalSellUnits; + if($getFREData->current_market_value_of_the_property < 0) { return 'SOLD'; }