Fix for Serialnumber & Discount Type

($discount_type) must be of type int
($serialnumber) must be of type string
This commit is contained in:
WShells
2024-04-16 16:48:01 +03:00
committed by jekkos
parent 9ad99a92e0
commit 9508770f47
2 changed files with 4 additions and 4 deletions

View File

@@ -193,7 +193,7 @@ class Receivings extends Secure_Controller
$raw_receiving_quantity = prepare_decimal($this->request->getPost('receiving_quantity'));
$description = $this->request->getPost('description', FILTER_SANITIZE_FULL_SPECIAL_CHARS); //TODO: Duplicated code
$serialnumber = $this->request->getPost('serialnumber', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$serialnumber = $this->request->getPost('serialnumber', FILTER_SANITIZE_FULL_SPECIAL_CHARS) ?? '';
$price = filter_var($raw_price, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
$quantity = filter_var($raw_quantity, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
$discount_type = $this->request->getPost('discount_type', FILTER_SANITIZE_NUMBER_INT);

View File

@@ -404,7 +404,7 @@ class Receiving_lib
* @param float $receiving_quantity
* @return bool
*/
public function edit_item($line, string $description, string $serialnumber, float $quantity, float $discount, int $discount_type, float $price, float $receiving_quantity): bool
public function edit_item($line, string $description, string $serialnumber, float $quantity, float $discount, ?int $discount_type, float $price, float $receiving_quantity): bool
{
$items = $this->get_cart();
if(isset($items[$line]))
@@ -416,7 +416,7 @@ class Receiving_lib
$line['receiving_quantity'] = $receiving_quantity;
$line['discount'] = $discount;
if(!is_null($discount_type)) //TODO: $discount_type is an int which means it will never be null and this if statement will always evaluate to true.
if(!is_null($discount_type))
{
$line['discount_type'] = $discount_type;
}
@@ -526,7 +526,7 @@ class Receiving_lib
* @param float $receiving_quantity
* @return string
*/
public function get_item_total(float $quantity, float $price, float $discount, int $discount_type, float $receiving_quantity): string
public function get_item_total(float $quantity, float $price, float $discount, ?int $discount_type, float $receiving_quantity): string
{
$extended_quantity = bcmul($quantity, $receiving_quantity);
$total = bcmul($extended_quantity, $price);