Merge branch '436-cmb-uat-requests' into '424-cmb-release'

Split invoice items with quantity more than 1. #436

See merge request jankstudio/resq!508
This commit is contained in:
Korina Cordero 2020-07-14 03:25:39 +00:00
commit 423ab20d77

View file

@ -368,6 +368,7 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
{
foreach ($jo_results as $jo)
{
// TODO: refactor this to call formatJobOrderData
$coord = $jo->getCoordinates();
$cust = $jo->getCustomer();
$cv = $jo->getCustomerVehicle();
@ -379,19 +380,24 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
$inv_items = [];
foreach ($inv->getItems() as $item)
{
$item_batt = $item->getBattery();
if ($item_batt == null)
$batt_id = null;
else
$batt_id = $item_batt->getID();
// if more than 1, split it into one of each of the same item
$item_qty = $item->getQuantity();
for ($i = 0; $i < $item_qty; $i++)
{
$item_batt = $item->getBattery();
if ($item_batt == null)
$batt_id = null;
else
$batt_id = $item_batt->getID();
$inv_items[] = [
'id' => $item->getID(),
'title' => $item->getTitle(),
'qty' => $item->getQuantity(),
'price' => $item->getPrice(),
'batt_id' => $batt_id,
];
$inv_items[] = [
'id' => $item->getID(),
'title' => $item->getTitle(),
'qty' => 1,
'price' => $item->getPrice(),
'batt_id' => $batt_id,
];
}
}
// promo
@ -507,6 +513,7 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
{
foreach ($jo_results as $jo)
{
// TODO: refactor this to call formatJobOrderData
$coord = $jo->getCoordinates();
$cust = $jo->getCustomer();
$cv = $jo->getCustomerVehicle();
@ -518,19 +525,24 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
$inv_items = [];
foreach ($inv->getItems() as $item)
{
$item_batt = $item->getBattery();
if ($item_batt == null)
$batt_id = null;
else
$batt_id = $item_batt->getID();
// if more than 1, split it into one of each of the same item
$item_qty = $item->getQuantity();
for ($i = 0; $i < $item_qty; $i++)
{
$item_batt = $item->getBattery();
if ($item_batt == null)
$batt_id = null;
else
$batt_id = $item_batt->getID();
$inv_items[] = [
'id' => $item->getID(),
'title' => $item->getTitle(),
'qty' => $item->getQuantity(),
'price' => $item->getPrice(),
'batt_id' => $batt_id,
];
$inv_items[] = [
'id' => $item->getID(),
'title' => $item->getTitle(),
'qty' => 1,
'price' => $item->getPrice(),
'batt_id' => $batt_id,
];
}
}
// promo
@ -620,19 +632,24 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
$inv_items = [];
foreach ($inv->getItems() as $item)
{
$item_batt = $item->getBattery();
if ($item_batt == null)
$batt_id = null;
else
$batt_id = $item_batt->getID();
// if more than 1, split it into one of each of the same item
$item_qty = $item->getQuantity();
for ($i = 0; $i < $item_qty; $i++)
{
$item_batt = $item->getBattery();
if ($item_batt == null)
$batt_id = null;
else
$batt_id = $item_batt->getID();
$inv_items[] = [
'id' => $item->getID(),
'title' => $item->getTitle(),
'qty' => $item->getQuantity(),
'price' => $item->getPrice(),
'batt_id' => $batt_id,
];
$inv_items[] = [
'id' => $item->getID(),
'title' => $item->getTitle(),
'qty' => 1,
'price' => $item->getPrice(),
'batt_id' => $batt_id,
];
}
}
// promo
@ -1299,19 +1316,24 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
$inv_items = [];
foreach ($inv->getItems() as $item)
{
$item_batt = $item->getBattery();
if ($item_batt == null)
$batt_id = null;
else
$batt_id = $item_batt->getID();
// if more than 1, split it into one of each of the same item
$item_qty = $item->getQuantity();
for ($i = 0; $i < $item_qty; $i++)
{
$item_batt = $item->getBattery();
if ($item_batt == null)
$batt_id = null;
else
$batt_id = $item_batt->getID();
$inv_items[] = [
'id' => $item->getID(),
'title' => $item->getTitle(),
'qty' => $item->getQuantity(),
'price' => $item->getPrice(),
'batt_id' => $batt_id,
];
$inv_items[] = [
'id' => $item->getID(),
'title' => $item->getTitle(),
'qty' => 1,
'price' => $item->getPrice(),
'batt_id' => $batt_id,
];
}
}
// promo
@ -1795,99 +1817,6 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
];
return $data;
/*
$coord = $jo->getCoordinates();
$cust = $jo->getCustomer();
$cv = $jo->getCustomerVehicle();
$v = $cv->getVehicle();
$inv = $jo->getInvoice();
$promo = $inv->getPromo();
// invoice items
$inv_items = [];
foreach ($inv->getItems() as $item)
{
$item_batt = $item->getBattery();
if ($item_batt == null)
$batt_id = null;
else
$batt_id = $item_batt->getID();
$inv_items[] = [
'id' => $item->getID(),
'title' => $item->getTitle(),
'qty' => $item->getQuantity(),
'price' => $item->getPrice(),
'batt_id' => $batt_id,
];
}
// promo
if ($promo != null)
{
$promo_data = [
'id' => $promo->getID(),
'name' => $promo->getName(),
'code' => $promo->getCode(),
'discount_rate' => $promo->getDiscountRate(),
'discount_apply' => $promo->getDiscountApply(),
];
}
else
{
$promo_data = null;
}
$trade_in_type = $jo->getTradeInType();
if (empty($trade_in_type))
$trade_in_type = 'none';
$data = [
'job_order' => [
'id' => $jo->getID(),
'service_type' => $jo->getServiceType(),
'date_schedule' => $jo->getDateSchedule()->format('Ymd H:i:s'),
'longitude' => $coord->getLongitude(),
'latitude' => $coord->getLatitude(),
'status' => $jo->getStatus(),
'date_status_change' => $jo->getDateStatusChange()->format('Ymd H:i:s'),
'customer' => [
'title' => $cust->getTitle(),
'first_name' => $cust->getFirstName(),
'last_name' => $cust->getLastName(),
'phone_mobile' => $this->country_code . $cust->getPhoneMobile(),
'phone_landline' => $this->country_code . $cust->getPhoneLandline(),
],
'vehicle' => [
'manufacturer' => $v->getManufacturer()->getName(),
'make' => $v->getMake(),
'model' => $cv->getModelYear(),
'plate_number' => $cv->getPlateNumber(),
'color' => $cv->getColor(),
],
'or_num' => $jo->getORNum(),
'or_name' => $jo->getORName(),
'delivery_instructions' => $jo->getDeliveryInstructions(),
'delivery_address' => $jo->getDeliveryAddress(),
'landmark' => $jo->getLandmark(),
'invoice' => [
'discount' => $inv->getDiscount(),
'trade_in' => $inv->getTradeIn(),
'total_price' => $inv->getTotalPrice(),
'vat' => $inv->getVat(),
'items' => $inv_items,
],
'mode_of_payment' => $jo->getModeOfPayment(),
'trade_in_type' => $trade_in_type,
'promo' => $promo_data,
// TODO: load the actual
'has_warranty_doc' => false,
'flag_coolant' => $jo->hasCoolant(),
'has_motolite' => $cv->hasMotoliteBattery(),
]
];
*/
}
public function getPaymentMethods(Request $req)