Split invoice items with quantity more than 1. #436
This commit is contained in:
parent
6cb3f1be66
commit
1a6ed417bf
1 changed files with 70 additions and 141 deletions
|
|
@ -368,6 +368,7 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
{
|
{
|
||||||
foreach ($jo_results as $jo)
|
foreach ($jo_results as $jo)
|
||||||
{
|
{
|
||||||
|
// TODO: refactor this to call formatJobOrderData
|
||||||
$coord = $jo->getCoordinates();
|
$coord = $jo->getCoordinates();
|
||||||
$cust = $jo->getCustomer();
|
$cust = $jo->getCustomer();
|
||||||
$cv = $jo->getCustomerVehicle();
|
$cv = $jo->getCustomerVehicle();
|
||||||
|
|
@ -379,19 +380,24 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
$inv_items = [];
|
$inv_items = [];
|
||||||
foreach ($inv->getItems() as $item)
|
foreach ($inv->getItems() as $item)
|
||||||
{
|
{
|
||||||
$item_batt = $item->getBattery();
|
// if more than 1, split it into one of each of the same item
|
||||||
if ($item_batt == null)
|
$item_qty = $item->getQuantity();
|
||||||
$batt_id = null;
|
for ($i = 0; $i < $item_qty; $i++)
|
||||||
else
|
{
|
||||||
$batt_id = $item_batt->getID();
|
$item_batt = $item->getBattery();
|
||||||
|
if ($item_batt == null)
|
||||||
|
$batt_id = null;
|
||||||
|
else
|
||||||
|
$batt_id = $item_batt->getID();
|
||||||
|
|
||||||
$inv_items[] = [
|
$inv_items[] = [
|
||||||
'id' => $item->getID(),
|
'id' => $item->getID(),
|
||||||
'title' => $item->getTitle(),
|
'title' => $item->getTitle(),
|
||||||
'qty' => $item->getQuantity(),
|
'qty' => 1,
|
||||||
'price' => $item->getPrice(),
|
'price' => $item->getPrice(),
|
||||||
'batt_id' => $batt_id,
|
'batt_id' => $batt_id,
|
||||||
];
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// promo
|
// promo
|
||||||
|
|
@ -507,6 +513,7 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
{
|
{
|
||||||
foreach ($jo_results as $jo)
|
foreach ($jo_results as $jo)
|
||||||
{
|
{
|
||||||
|
// TODO: refactor this to call formatJobOrderData
|
||||||
$coord = $jo->getCoordinates();
|
$coord = $jo->getCoordinates();
|
||||||
$cust = $jo->getCustomer();
|
$cust = $jo->getCustomer();
|
||||||
$cv = $jo->getCustomerVehicle();
|
$cv = $jo->getCustomerVehicle();
|
||||||
|
|
@ -518,19 +525,24 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
$inv_items = [];
|
$inv_items = [];
|
||||||
foreach ($inv->getItems() as $item)
|
foreach ($inv->getItems() as $item)
|
||||||
{
|
{
|
||||||
$item_batt = $item->getBattery();
|
// if more than 1, split it into one of each of the same item
|
||||||
if ($item_batt == null)
|
$item_qty = $item->getQuantity();
|
||||||
$batt_id = null;
|
for ($i = 0; $i < $item_qty; $i++)
|
||||||
else
|
{
|
||||||
$batt_id = $item_batt->getID();
|
$item_batt = $item->getBattery();
|
||||||
|
if ($item_batt == null)
|
||||||
|
$batt_id = null;
|
||||||
|
else
|
||||||
|
$batt_id = $item_batt->getID();
|
||||||
|
|
||||||
$inv_items[] = [
|
$inv_items[] = [
|
||||||
'id' => $item->getID(),
|
'id' => $item->getID(),
|
||||||
'title' => $item->getTitle(),
|
'title' => $item->getTitle(),
|
||||||
'qty' => $item->getQuantity(),
|
'qty' => 1,
|
||||||
'price' => $item->getPrice(),
|
'price' => $item->getPrice(),
|
||||||
'batt_id' => $batt_id,
|
'batt_id' => $batt_id,
|
||||||
];
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// promo
|
// promo
|
||||||
|
|
@ -620,19 +632,24 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
$inv_items = [];
|
$inv_items = [];
|
||||||
foreach ($inv->getItems() as $item)
|
foreach ($inv->getItems() as $item)
|
||||||
{
|
{
|
||||||
$item_batt = $item->getBattery();
|
// if more than 1, split it into one of each of the same item
|
||||||
if ($item_batt == null)
|
$item_qty = $item->getQuantity();
|
||||||
$batt_id = null;
|
for ($i = 0; $i < $item_qty; $i++)
|
||||||
else
|
{
|
||||||
$batt_id = $item_batt->getID();
|
$item_batt = $item->getBattery();
|
||||||
|
if ($item_batt == null)
|
||||||
|
$batt_id = null;
|
||||||
|
else
|
||||||
|
$batt_id = $item_batt->getID();
|
||||||
|
|
||||||
$inv_items[] = [
|
$inv_items[] = [
|
||||||
'id' => $item->getID(),
|
'id' => $item->getID(),
|
||||||
'title' => $item->getTitle(),
|
'title' => $item->getTitle(),
|
||||||
'qty' => $item->getQuantity(),
|
'qty' => 1,
|
||||||
'price' => $item->getPrice(),
|
'price' => $item->getPrice(),
|
||||||
'batt_id' => $batt_id,
|
'batt_id' => $batt_id,
|
||||||
];
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// promo
|
// promo
|
||||||
|
|
@ -1299,19 +1316,24 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
$inv_items = [];
|
$inv_items = [];
|
||||||
foreach ($inv->getItems() as $item)
|
foreach ($inv->getItems() as $item)
|
||||||
{
|
{
|
||||||
$item_batt = $item->getBattery();
|
// if more than 1, split it into one of each of the same item
|
||||||
if ($item_batt == null)
|
$item_qty = $item->getQuantity();
|
||||||
$batt_id = null;
|
for ($i = 0; $i < $item_qty; $i++)
|
||||||
else
|
{
|
||||||
$batt_id = $item_batt->getID();
|
$item_batt = $item->getBattery();
|
||||||
|
if ($item_batt == null)
|
||||||
|
$batt_id = null;
|
||||||
|
else
|
||||||
|
$batt_id = $item_batt->getID();
|
||||||
|
|
||||||
$inv_items[] = [
|
$inv_items[] = [
|
||||||
'id' => $item->getID(),
|
'id' => $item->getID(),
|
||||||
'title' => $item->getTitle(),
|
'title' => $item->getTitle(),
|
||||||
'qty' => $item->getQuantity(),
|
'qty' => 1,
|
||||||
'price' => $item->getPrice(),
|
'price' => $item->getPrice(),
|
||||||
'batt_id' => $batt_id,
|
'batt_id' => $batt_id,
|
||||||
];
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// promo
|
// promo
|
||||||
|
|
@ -1795,99 +1817,6 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
];
|
];
|
||||||
|
|
||||||
return $data;
|
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)
|
public function getPaymentMethods(Request $req)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue