Receivings Bugfixes

- Fixed incorrect variable name
- Return empty string on null
- Added return types for mixed return functions

Signed-off-by: objecttothis <objecttothis@gmail.com>
This commit is contained in:
objecttothis
2024-04-16 16:16:56 +04:00
committed by jekkos
parent 5500d3989f
commit b593de9f83
3 changed files with 10 additions and 10 deletions

View File

@@ -172,9 +172,9 @@ class Receiving_lib
/**
* @return string|null
*/
public function get_reference(): ?string
public function get_reference(): string
{
return $this->session->get('recv_reference');
return $this->session->get('recv_reference') ?? '';
}
/**

View File

@@ -56,10 +56,10 @@ class Item_quantity extends Model
/**
* @param int $item_id
* @param int $location_id
* @return array|object|stdClass|null
* @return array|Item_quantity|null
*/
public function get_item_quantity(int $item_id, int $location_id)
{
public function get_item_quantity(int $item_id, int $location_id): array|Item_quantity|StdClass|null
{
$builder = $this->db->table('item_quantities');
$builder->where('item_id', $item_id);
$builder->where('location_id', $location_id);
@@ -68,7 +68,7 @@ class Item_quantity extends Model
if(empty($result))
{
//Get empty base parent object, as $item_id is NOT an item
$result = new stdClass();
$result = model(Item_quantity::class);
//Get all the fields from items table (TODO: to be reviewed)
foreach($this->db->getFieldNames('item_quantities') as $field)

View File

@@ -138,7 +138,7 @@ class Receiving extends Model
foreach($items as $line => $item_data)
{
$config = config(OSPOS::class)->settings;
$cur_item_info = $item->get_info($item['item_id']);
$cur_item_info = $item->get_info($item_data['item_id']);
$receivings_items_data = [
'receiving_id' => $receiving_id,
@@ -166,9 +166,9 @@ class Receiving extends Model
}
//Update stock quantity
$item_quantity = $item_quantity->get_item_quantity($item['item_id'], $item['item_location']);
$item_quantity_value = $item_quantity->get_item_quantity($item_data['item_id'], $item_data['item_location']);
$item_quantity->save_value([
'quantity' => $item_quantity->quantity + $items_received,
'quantity' => $item_quantity_value->quantity + $items_received,
'item_id' => $item_data['item_id'],
'location_id' => $item_data['item_location']],
$item_data['item_id'],
@@ -180,7 +180,7 @@ class Receiving extends Model
'trans_date' => date('Y-m-d H:i:s'),
'trans_items' => $item_data['item_id'],
'trans_user' => $employee_id,
'trans_location' => $item['item_location'],
'trans_location' => $item_data['item_location'],
'trans_comment' => $recv_remarks,
'trans_inventory' => $items_received
];