Minor updates to order process

This commit is contained in:
Deon George
2019-01-24 14:40:33 +11:00
parent a9f545412b
commit b19f01d7a4
9 changed files with 217 additions and 20 deletions

View File

@@ -50,8 +50,13 @@ class Service extends Model
];
private $inactive_status = [
'CANCELLED',
'CANCELLED', // @todo Check if these should be changed to ORDER-CANCELLED
'ORDER-REJECTED',
'ORDER-CANCELLED',
];
private $valid_status = [
'ORDER-SUBMIT' => ['accept'=>'ORDER-SENT','reject'=>'ORDER-REJECTED'],
];
public function account()
@@ -159,6 +164,18 @@ class Service extends Model
return $this->date_next_invoice ? $this->date_next_invoice->format('Y-m-d') : NULL;
}
/**
* This function will present the Order Info Details
*/
public function getOrderInfoDetailsAttribute()
{
$result = '';
foreach ($this->order_info as $k=>$v)
$result .= sprintf('%s: <b>%s</b><br>',ucfirst($k),$v);
return $result;
}
public function getProductNameAttribute()
{
// @todo: All services should be linked to a product. This might require data cleaning for old services not linked to a product.
@@ -238,4 +255,15 @@ class Service extends Model
default: return NULL;
}
}
/**
* Return if the proposed status is valid.
*
* @param string $status
* @return string | NULL
*/
public function validStatus(string $status)
{
return array_get(array_get($this->valid_status,$this->order_status,[]),$status,NULL);
}
}