Add regional pricing support to job order updates on rider app #783

This commit is contained in:
Ramon Gutierrez 2024-03-15 16:24:09 +08:00
parent a59aa0f66d
commit bff89a6817

View file

@ -1204,7 +1204,7 @@ class RiderAppController extends ApiController
]); ]);
} }
public function updateJobOrder(Request $req, EntityManagerInterface $em, InvoiceGeneratorInterface $ic) public function updateJobOrder(Request $req, EntityManagerInterface $em, InvoiceGeneratorInterface $ic, PriceTierManager $pt_manager)
{ {
$items = json_decode(file_get_contents('php://input'), true); $items = json_decode(file_get_contents('php://input'), true);
@ -1301,7 +1301,7 @@ class RiderAppController extends ApiController
// need to get the existing invoice items using jo id and invoice id // need to get the existing invoice items using jo id and invoice id
$existing_ii = $this->getInvoiceItems($em, $jo); $existing_ii = $this->getInvoiceItems($em, $jo);
$this->generateUpdatedInvoice($em, $ic, $jo, $existing_ii, $ti_items, $promo); $this->generateUpdatedInvoice($em, $ic, $jo, $existing_ii, $ti_items, $promo, $pt_manager);
$data = []; $data = [];
return new APIResponse(true, 'Job order updated.', $data); return new APIResponse(true, 'Job order updated.', $data);
@ -1453,8 +1453,7 @@ class RiderAppController extends ApiController
return new APIResponse(true, 'Job order service changed.', $data); return new APIResponse(true, 'Job order service changed.', $data);
} }
protected function generateUpdatedInvoice(EntityManagerInterface $em, InvoiceGeneratorInterface $ic, JobOrder $jo, protected function generateUpdatedInvoice(EntityManagerInterface $em, InvoiceGeneratorInterface $ic, JobOrder $jo, $existing_ii, $trade_in_items, $promo, PriceTierManager $pt_manager)
$existing_ii, $trade_in_items, $promo)
{ {
// get the service type // get the service type
$stype = $jo->getServiceType(); $stype = $jo->getServiceType();
@ -1488,6 +1487,10 @@ class RiderAppController extends ApiController
->setHasCoolant($flag_coolant) ->setHasCoolant($flag_coolant)
->setIsTaxable(); ->setIsTaxable();
// set price tier
$pt_id = $pt_manager->getPriceTier($jo->getCoordinates());
$icrit->setPriceTier($pt_id);
// at this point, all information should be valid // at this point, all information should be valid
// assuming JO information is already valid since this // assuming JO information is already valid since this
// is in the system already // is in the system already