Merge branch '159-general-fixes-and-tweaking' into 'master'
Resolve "General fixes and tweaking" Closes #159 See merge request jankstudio/resq!161
This commit is contained in:
commit
2ca212e1b7
4 changed files with 49 additions and 1 deletions
|
|
@ -745,6 +745,8 @@ class APIController extends Controller
|
||||||
if ($res->isError())
|
if ($res->isError())
|
||||||
return $res->getReturnResponse();
|
return $res->getReturnResponse();
|
||||||
|
|
||||||
|
$trade_in = $req->request->get('trade_in');
|
||||||
|
|
||||||
$jo = new JobOrder();
|
$jo = new JobOrder();
|
||||||
$jo->setSource(TransactionOrigin::MOBILE_APP)
|
$jo->setSource(TransactionOrigin::MOBILE_APP)
|
||||||
->setStatus(JOStatus::PENDING)
|
->setStatus(JOStatus::PENDING)
|
||||||
|
|
@ -752,6 +754,7 @@ class APIController extends Controller
|
||||||
->setTier1Notes('')
|
->setTier1Notes('')
|
||||||
->setTier2Notes('')
|
->setTier2Notes('')
|
||||||
->setDeliveryAddress('Set by mobile application')
|
->setDeliveryAddress('Set by mobile application')
|
||||||
|
->setTradeInType($trade_in)
|
||||||
// TODO: error check for valid mode of payment
|
// TODO: error check for valid mode of payment
|
||||||
->setModeOfPayment($req->request->get('mode_of_payment'));
|
->setModeOfPayment($req->request->get('mode_of_payment'));
|
||||||
|
|
||||||
|
|
@ -852,7 +855,6 @@ class APIController extends Controller
|
||||||
|
|
||||||
// check trade-in
|
// check trade-in
|
||||||
// only allow motolite, other, none
|
// only allow motolite, other, none
|
||||||
$trade_in = $req->request->get('trade_in');
|
|
||||||
switch ($trade_in)
|
switch ($trade_in)
|
||||||
{
|
{
|
||||||
case TradeInType::MOTOLITE:
|
case TradeInType::MOTOLITE:
|
||||||
|
|
|
||||||
|
|
@ -286,6 +286,17 @@ class JobOrderController extends BaseController
|
||||||
|
|
||||||
$ierror = $this->invoicePromo($em, $criteria, $req->request->get('invoice_promo'));
|
$ierror = $this->invoicePromo($em, $criteria, $req->request->get('invoice_promo'));
|
||||||
|
|
||||||
|
// check for trade in so we can mark it for mobile app
|
||||||
|
foreach ($invoice_items as $item)
|
||||||
|
{
|
||||||
|
// get first trade-in
|
||||||
|
if (!empty($item['trade_in']))
|
||||||
|
{
|
||||||
|
$obj->setTradeInType($item['trade_in']);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!$ierror)
|
if (!$ierror)
|
||||||
$ierror = $this->invoiceBatteries($em, $criteria, $invoice_items);
|
$ierror = $this->invoiceBatteries($em, $criteria, $invoice_items);
|
||||||
|
|
||||||
|
|
@ -467,7 +478,20 @@ class JobOrderController extends BaseController
|
||||||
$invoice_items = $req->request->get('invoice_items');
|
$invoice_items = $req->request->get('invoice_items');
|
||||||
|
|
||||||
if (!$ierror && !empty($invoice_items))
|
if (!$ierror && !empty($invoice_items))
|
||||||
|
{
|
||||||
|
// check for trade in so we can mark it for mobile app
|
||||||
|
foreach ($invoice_items as $item)
|
||||||
|
{
|
||||||
|
// get first trade-in
|
||||||
|
if (!empty($item['trade_in']))
|
||||||
|
{
|
||||||
|
$obj->setTradeInType($item['trade_in']);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$ierror = $this->invoiceBatteries($em, $criteria, $invoice_items);
|
$ierror = $this->invoiceBatteries($em, $criteria, $invoice_items);
|
||||||
|
}
|
||||||
|
|
||||||
if ($ierror)
|
if ($ierror)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -363,6 +363,10 @@ class RAPIController extends Controller
|
||||||
$promo_data = null;
|
$promo_data = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$trade_in_type = $jo->getTradeInType();
|
||||||
|
if (empty($trade_in_type))
|
||||||
|
$trade_in_type = 'none';
|
||||||
|
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'job_order' => [
|
'job_order' => [
|
||||||
|
|
@ -398,6 +402,7 @@ class RAPIController extends Controller
|
||||||
'items' => $inv_items,
|
'items' => $inv_items,
|
||||||
],
|
],
|
||||||
'mode_of_payment' => $jo->getModeOfPayment(),
|
'mode_of_payment' => $jo->getModeOfPayment(),
|
||||||
|
'trade_in_type' => $trade_in_type,
|
||||||
'promo' => $promo_data,
|
'promo' => $promo_data,
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -232,6 +232,11 @@ class JobOrder
|
||||||
*/
|
*/
|
||||||
protected $events;
|
protected $events;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="string", length=25, nullable=true)
|
||||||
|
*/
|
||||||
|
protected $trade_in_type;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->date_create = new DateTime();
|
$this->date_create = new DateTime();
|
||||||
|
|
@ -246,6 +251,7 @@ class JobOrder
|
||||||
$this->promo_detail = '';
|
$this->promo_detail = '';
|
||||||
|
|
||||||
$this->events = new ArrayCollection();
|
$this->events = new ArrayCollection();
|
||||||
|
$this->trade_in_type = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getID()
|
public function getID()
|
||||||
|
|
@ -636,4 +642,15 @@ class JobOrder
|
||||||
{
|
{
|
||||||
return $this->status == JOStatus::CANCELLED;
|
return $this->status == JOStatus::CANCELLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setTradeInType($type)
|
||||||
|
{
|
||||||
|
$this->trade_in_type = $type;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTradeInType()
|
||||||
|
{
|
||||||
|
return $this->trade_in_type;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue