Update subscription fee endpoint to be specific to each vehicle model #799
This commit is contained in:
parent
b67f960055
commit
4f5560f6f7
8 changed files with 26 additions and 27 deletions
|
|
@ -322,7 +322,7 @@ apiv2_static_content:
|
|||
|
||||
# subscription
|
||||
apiv2_subscription_fee:
|
||||
path: /apiv2/subscription/fee
|
||||
path: /apiv2/subscription/{vid}/fee
|
||||
controller: App\Controller\CustomerAppAPI\SubscriptionController::getRecurringFee
|
||||
methods: [GET]
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ parameters:
|
|||
ios_app_version: "%env(IOS_APP_VERSION)%"
|
||||
insurance_premiums_banner_url: "%env(INSURANCE_PREMIUMS_BANNER_URL)%"
|
||||
enabled_hub_filters: "%env(ENABLED_HUB_FILTERS)%"
|
||||
subscription_recurring_fee: "%env(SUBSCRIPTION_RECURRING_FEE)%"
|
||||
subscription_paymongo_public_key: "%env(SUBSCRIPTION_PAYMONGO_PUBLIC_KEY)%"
|
||||
|
||||
services:
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ class BatterySizeController extends Controller
|
|||
->setTIPricePremium($req->request->get('tip_premium'))
|
||||
->setTIPriceOther($req->request->get('tip_other'))
|
||||
->setTIPriceLazada($req->request->get('tip_lazada'))
|
||||
->setSubMSRP($req->request->get('sub_msrp'));
|
||||
->setSubRecurringFee($req->request->get('sub_recurring_fee'));
|
||||
}
|
||||
|
||||
public function addSubmit(Request $req, ValidatorInterface $validator)
|
||||
|
|
|
|||
|
|
@ -5,11 +5,11 @@ namespace App\Controller\CustomerAppAPI;
|
|||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Catalyst\ApiBundle\Component\Response as ApiResponse;
|
||||
|
||||
use App\Entity\CustomerVehicle;
|
||||
use App\Entity\Vehicle;
|
||||
|
||||
class SubscriptionController extends ApiController
|
||||
{
|
||||
public function getRecurringFee(Request $req, $cv_id)
|
||||
public function getRecurringFee(Request $req, $vid)
|
||||
{
|
||||
// check requirements
|
||||
$validity = $this->validateRequest($req);
|
||||
|
|
@ -18,22 +18,22 @@ class SubscriptionController extends ApiController
|
|||
return new ApiResponse(false, $validity['error']);
|
||||
}
|
||||
|
||||
// get customer vehicle
|
||||
$cv = $this->em->getRepository(CustomerVehicle::class)->find($cv_id);
|
||||
|
||||
// check if it exists
|
||||
if ($cv == null) {
|
||||
return new ApiResponse(false, 'Vehicle does not exist.');
|
||||
// get vehicle
|
||||
$vehicle = $this->em->getRepository(Vehicle::class)->find($vid);
|
||||
if ($vehicle == null) {
|
||||
return new ApiResponse(false, 'Invalid vehicle.');
|
||||
}
|
||||
|
||||
// check if it's owned by customer
|
||||
if ($cv->getCustomer()->getID() != $this->session->getCustomer()->getID()) {
|
||||
return new ApiResponse(false, 'Invalid vehicle.');
|
||||
// get compatible batteries
|
||||
$batts = $vehicle->getActiveBatteries();
|
||||
|
||||
if (!empty($batts)) {
|
||||
$fee = $batts[0]->getSize()->getSubRecurringFee() ?? 0;
|
||||
}
|
||||
|
||||
// response
|
||||
return new ApiResponse(true, '', [
|
||||
'amount' => $this->getParameter('subscription_recurring_fee'),
|
||||
'amount' => $fee,
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -393,7 +393,7 @@ class VehicleController extends ApiController
|
|||
// TODO: possibly refactor this bit
|
||||
// if no valid previous JO is found, base the trade-in value on recommended batteries
|
||||
if (!$previous_jo_found) {
|
||||
$comp_batteries = $cv->getVehicle()->getBatteries();
|
||||
$comp_batteries = $cv->getVehicle()->getActiveBatteries();
|
||||
|
||||
// get the lowest trade-in value from the list of batteries
|
||||
if (!empty($comp_batteries)) {
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ class BatterySize
|
|||
/**
|
||||
* @ORM\Column(type="decimal", precision=7, scale=2, nullable=true)
|
||||
*/
|
||||
protected $sub_msrp;
|
||||
protected $sub_recurring_fee;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
|
@ -70,7 +70,7 @@ class BatterySize
|
|||
$this->tip_premium = 0;
|
||||
$this->tip_other = 0;
|
||||
$this->tip_lazada = 0;
|
||||
$this->sub_msrp = 0;
|
||||
$this->sub_recurring_fee = 0;
|
||||
}
|
||||
|
||||
public function getID()
|
||||
|
|
@ -156,14 +156,14 @@ class BatterySize
|
|||
return $this->tip_lazada;
|
||||
}
|
||||
|
||||
public function setSubMSRP($sub_msrp)
|
||||
public function setSubRecurringFee($sub_recurring_fee)
|
||||
{
|
||||
$this->sub_msrp = $sub_msrp;
|
||||
$this->sub_recurring_fee = $sub_recurring_fee;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSubMSRP()
|
||||
public function getSubRecurringFee()
|
||||
{
|
||||
return $this->sub_msrp;
|
||||
return $this->sub_recurring_fee;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,12 +81,12 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="form-group m-form__group row no-border">
|
||||
<label class="col-lg-3 col-form-label" data-field="sub_msrp">
|
||||
{% trans %}battery_Size_sub_msrp{% endtrans %}
|
||||
<label class="col-lg-3 col-form-label" data-field="sub_recurring_fee">
|
||||
{% trans %}battery_Size_sub_recurring_fee{% endtrans %}
|
||||
</label>
|
||||
<div class="col-lg-9">
|
||||
<input type="text" name="sub_msrp" class="form-control m-input" value="{{ obj.getSubMSRP }}">
|
||||
<div class="form-control-feedback hide" data-field="sub_msrp"></div>
|
||||
<input type="text" name="sub_recurring_fee" class="form-control m-input" value="{{ obj.getSubRecurringFee }}">
|
||||
<div class="form-control-feedback hide" data-field="sub_recurring_fee"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ battery_size_tradein_brand: Trade-in Motolite
|
|||
battery_size_tradein_premium: Trade-in Premium
|
||||
battery_size_tradein_other: Trade-in Other
|
||||
battery_size_tradein_lazada: Trade-in Lazada
|
||||
battery_Size_sub_msrp: Subscription MSRP
|
||||
battery_Size_sub_recurring_fee: Subscription Recurring Fee
|
||||
add_cust_vehicle_battery_info: This vehicle is using a Motolite battery
|
||||
jo_title_pdf: Motolite Res-Q Job Order
|
||||
country_code_prefix: '+63'
|
||||
|
|
|
|||
Loading…
Reference in a new issue