mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-04-05 07:34:49 -04:00
Remove prepare_decimal and filter_var
This commit is contained in:
@@ -140,7 +140,6 @@ class OSPOSRules
|
||||
*/
|
||||
public function decimal_locale(string $candidate, ?string &$error = null): bool
|
||||
{
|
||||
$candidate = prepare_decimal($candidate);
|
||||
$validation = Services::validation();
|
||||
|
||||
$validation->setRules([
|
||||
|
||||
@@ -228,24 +228,16 @@ class Cashups extends Secure_Controller
|
||||
$close_date = $this->request->getPost('close_date');
|
||||
$close_date_formatter = date_create_from_format($this->config['dateformat'] . ' ' . $this->config['timeformat'], $close_date);
|
||||
|
||||
$open_amount_cash = prepare_decimal($this->request->getPost('open_amount_cash'));
|
||||
$transfer_amount_cash = prepare_decimal($this->request->getPost('transfer_amount_cash'));
|
||||
$closed_amount_cash = prepare_decimal($this->request->getPost('closed_amount_cash'));
|
||||
$closed_amount_due = prepare_decimal($this->request->getPost('closed_amount_due'));
|
||||
$closed_amount_card = prepare_decimal($this->request->getPost('closed_amount_card'));
|
||||
$closed_amount_check = prepare_decimal($this->request->getPost('closed_amount_check'));
|
||||
$closed_amount_total = prepare_decimal($this->request->getPost('closed_amount_total'));
|
||||
|
||||
$cash_up_data = [
|
||||
'open_date' => $open_date_formatter->format('Y-m-d H:i:s'),
|
||||
'close_date' => $close_date_formatter->format('Y-m-d H:i:s'),
|
||||
'open_amount_cash' => parse_decimals(filter_var($open_amount_cash, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION)),
|
||||
'transfer_amount_cash' => parse_decimals(filter_var($transfer_amount_cash, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION)),
|
||||
'closed_amount_cash' => parse_decimals(filter_var($closed_amount_cash, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION)),
|
||||
'closed_amount_due' => parse_decimals(filter_var($closed_amount_due, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION)),
|
||||
'closed_amount_card' => parse_decimals(filter_var($closed_amount_card, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION)),
|
||||
'closed_amount_check' => parse_decimals(filter_var($closed_amount_check, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION)),
|
||||
'closed_amount_total' => parse_decimals(filter_var($closed_amount_total, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION)),
|
||||
'open_amount_cash' => parse_decimals($this->request->getPost('open_amount_cash')),
|
||||
'transfer_amount_cash' => parse_decimals($this->request->getPost('transfer_amount_cash')),
|
||||
'closed_amount_cash' => parse_decimals($this->request->getPost('closed_amount_cash')),
|
||||
'closed_amount_due' => parse_decimals($this->request->getPost('closed_amount_due')),
|
||||
'closed_amount_card' => parse_decimals($this->request->getPost('closed_amount_card')),
|
||||
'closed_amount_check' => parse_decimals($this->request->getPost('closed_amount_check')),
|
||||
'closed_amount_total' => parse_decimals($this->request->getPost('closed_amount_total')),
|
||||
'note' => $this->request->getPost('note') != null,
|
||||
'description' => $this->request->getPost('description', FILTER_SANITIZE_FULL_SPECIAL_CHARS),
|
||||
'open_employee_id' => $this->request->getPost('open_employee_id', FILTER_SANITIZE_NUMBER_INT),
|
||||
@@ -296,19 +288,12 @@ class Cashups extends Secure_Controller
|
||||
*/
|
||||
public function ajax_cashup_total(): void
|
||||
{
|
||||
$raw_open_amount_cash = $this->request->getPost('open_amount_cash');
|
||||
$raw_transfer_amount_cash = $this->request->getPost('transfer_amount_cash');
|
||||
$raw_closed_amount_cash = $this->request->getPost('closed_amount_cash');
|
||||
$raw_closed_amount_due = $this->request->getPost('closed_amount_due');
|
||||
$raw_closed_amount_card = $this->request->getPost('closed_amount_card');
|
||||
$raw_closed_amount_check = $this->request->getPost('closed_amount_check');
|
||||
|
||||
$open_amount_cash = parse_decimals(filter_var(prepare_decimal($raw_open_amount_cash), FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION));
|
||||
$transfer_amount_cash = parse_decimals(filter_var(prepare_decimal($raw_transfer_amount_cash), FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION));
|
||||
$closed_amount_cash = parse_decimals(filter_var(prepare_decimal($raw_closed_amount_cash), FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION));
|
||||
$closed_amount_due = parse_decimals(filter_var(prepare_decimal($raw_closed_amount_due), FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION));
|
||||
$closed_amount_card = parse_decimals(filter_var(prepare_decimal($raw_closed_amount_card), FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION));
|
||||
$closed_amount_check = parse_decimals(filter_var(prepare_decimal($raw_closed_amount_check), FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION));
|
||||
$open_amount_cash = parse_decimals($this->request->getPost('open_amount_cash'));
|
||||
$transfer_amount_cash = parse_decimals($this->request->getPost('transfer_amount_cash'));
|
||||
$closed_amount_cash = parse_decimals($this->request->getPost('closed_amount_cash'));
|
||||
$closed_amount_due = parse_decimals($this->request->getPost('closed_amount_due'));
|
||||
$closed_amount_card = parse_decimals($this->request->getPost('closed_amount_card'));
|
||||
$closed_amount_check = parse_decimals($this->request->getPost('closed_amount_check'));
|
||||
|
||||
$total = $this->_calculate_total($open_amount_cash, $transfer_amount_cash, $closed_amount_due, $closed_amount_cash, $closed_amount_card, $closed_amount_check); //TODO: hungarian notation
|
||||
|
||||
|
||||
@@ -360,16 +360,13 @@ class Config extends Secure_Controller
|
||||
*/
|
||||
public function postSaveGeneral(): void
|
||||
{
|
||||
$default_sales_discount = prepare_decimal($this->request->getPost('default_sales_discount'));
|
||||
$default_receivings_discount = prepare_decimal($this->request->getPost('default_receivings_discount'));
|
||||
|
||||
$batch_save_data = [
|
||||
'theme' => $this->request->getPost('theme'),
|
||||
'login_form' => $this->request->getPost('login_form'),
|
||||
'default_sales_discount_type' => $this->request->getPost('default_sales_discount_type') != null,
|
||||
'default_sales_discount' => filter_var($default_sales_discount, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION),
|
||||
'default_sales_discount' => parse_decimals($this->request->getPost('default_sales_discount')),
|
||||
'default_receivings_discount_type' => $this->request->getPost('default_receivings_discount_type') != null,
|
||||
'default_receivings_discount' => filter_var($default_receivings_discount, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION),
|
||||
'default_receivings_discount' => parse_decimals($this->request->getPost('default_receivings_discount')),
|
||||
'enforce_privacy' => $this->request->getPost('enforce_privacy') != null,
|
||||
'receiving_calculate_average_price' => $this->request->getPost('receiving_calculate_average_price') != null,
|
||||
'lines_per_page' => $this->request->getPost('lines_per_page', FILTER_SANITIZE_NUMBER_INT),
|
||||
@@ -772,8 +769,8 @@ class Config extends Secure_Controller
|
||||
*/
|
||||
public function postSaveTax(): void
|
||||
{
|
||||
$default_tax_1_rate = prepare_decimal($this->request->getPost('default_tax_1_rate'));
|
||||
$default_tax_2_rate = prepare_decimal($this->request->getPost('default_tax_2_rate'));
|
||||
$default_tax_1_rate = $this->request->getPost('default_tax_1_rate');
|
||||
$default_tax_2_rate = $this->request->getPost('default_tax_2_rate');
|
||||
|
||||
$batch_save_data = [
|
||||
'default_tax_1_rate' => parse_tax(filter_var($default_tax_1_rate, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION)),
|
||||
|
||||
@@ -286,14 +286,12 @@ class Customers extends Persons
|
||||
|
||||
$date_formatter = date_create_from_format($this->config['dateformat'] . ' ' . $this->config['timeformat'], $this->request->getPost('date'));
|
||||
|
||||
$discount = prepare_decimal($this->request->getPost('discount'));
|
||||
|
||||
$customer_data = [
|
||||
'consent' => $this->request->getPost('consent') != null,
|
||||
'account_number' => $this->request->getPost('account_number') == '' ? null : $this->request->getPost('account_number'),
|
||||
'tax_id' => $this->request->getPost('tax_id'),
|
||||
'company_name' => $this->request->getPost('company_name') == '' ? null : $this->request->getPost('company_name'),
|
||||
'discount' => $this->request->getPost('discount') == '' ? 0.00 : filter_var($discount, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION),
|
||||
'discount' => $this->request->getPost('discount') == '' ? 0.00 : parse_decimals($this->request->getPost('discount')),
|
||||
'discount_type' => $this->request->getPost('discount_type') == null ? PERCENT : $this->request->getPost('discount_type', FILTER_SANITIZE_NUMBER_INT),
|
||||
'package_id' => $this->request->getPost('package_id') == '' ? null : $this->request->getPost('package_id'),
|
||||
'taxable' => $this->request->getPost('taxable') != null,
|
||||
|
||||
@@ -158,15 +158,13 @@ class Expenses extends Secure_Controller
|
||||
$newdate = $this->request->getPost('date', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
|
||||
$date_formatter = date_create_from_format($config['dateformat'] . ' ' . $config['timeformat'], $newdate);
|
||||
$amount = prepare_decimal($this->request->getPost('amount'));
|
||||
$tax_amount = prepare_decimal($this->request->getPost('tax_amount'));
|
||||
|
||||
$expense_data = [
|
||||
'date' => $date_formatter->format('Y-m-d H:i:s'),
|
||||
'supplier_id' => $this->request->getPost('supplier_id') == '' ? null : $this->request->getPost('supplier_id', FILTER_SANITIZE_NUMBER_INT),
|
||||
'supplier_tax_code' => $this->request->getPost('supplier_tax_code', FILTER_SANITIZE_FULL_SPECIAL_CHARS),
|
||||
'amount' => filter_var($amount, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION),
|
||||
'tax_amount' => filter_var($tax_amount, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION),
|
||||
'amount' => parse_decimals($this->request->getPost('amount')),
|
||||
'tax_amount' => parse_decimals($this->request->getPost('tax_amount')),
|
||||
'payment_type' => $this->request->getPost('payment_type', FILTER_SANITIZE_FULL_SPECIAL_CHARS),
|
||||
'expense_category_id' => $this->request->getPost('expense_category_id', FILTER_SANITIZE_NUMBER_INT),
|
||||
'description' => $this->request->getPost('description', FILTER_SANITIZE_FULL_SPECIAL_CHARS),
|
||||
|
||||
@@ -120,17 +120,16 @@ class Giftcards extends Secure_Controller
|
||||
public function postSave(int $giftcard_id = NEW_ENTRY): void
|
||||
{
|
||||
$giftcard_number = $this->request->getPost('giftcard_number', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$giftcard_amount = prepare_decimal($this->request->getPost('giftcard_amount'));
|
||||
|
||||
if($giftcard_id == NEW_ENTRY && trim($giftcard_number) == '')
|
||||
{
|
||||
$giftcard_number = $this->giftcard->generate_unique_giftcard_name(filter_var($giftcard_amount, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION));
|
||||
$giftcard_number = $this->giftcard->generate_unique_giftcard_name($giftcard_number);
|
||||
}
|
||||
|
||||
$giftcard_data = [
|
||||
'record_time' => date('Y-m-d H:i:s'),
|
||||
'giftcard_number' => $giftcard_number,
|
||||
'value' => filter_var($giftcard_amount, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION),
|
||||
'value' => parse_decimals($this->request->getPost('giftcard_amount')),
|
||||
'person_id' => $this->request->getPost('person_id') == '' ? null : $this->request->getPost('person_id', FILTER_SANITIZE_NUMBER_INT)
|
||||
];
|
||||
|
||||
|
||||
@@ -169,13 +169,11 @@ class Item_kits extends Secure_Controller
|
||||
*/
|
||||
public function postSave(int $item_kit_id = NEW_ENTRY): void
|
||||
{
|
||||
$kit_discount = prepare_decimal($this->request->getPost('kit_discount'));
|
||||
|
||||
$item_kit_data = [
|
||||
'name' => $this->request->getPost('name'),
|
||||
'item_kit_number' => $this->request->getPost('item_kit_number'),
|
||||
'item_id' => $this->request->getPost('kit_item_id') ? null : intval($this->request->getPost('kit_item_id')),
|
||||
'kit_discount' => filter_var($kit_discount,FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION),
|
||||
'kit_discount' => parse_decimals($this->request->getPost('kit_discount')),
|
||||
'kit_discount_type' => $this->request->getPost('kit_discount_type') === null ? PERCENT : intval($this->request->getPost('kit_discount_type')),
|
||||
'price_option' => $this->request->getPost('price_option') === null ? PRICE_ALL : intval($this->request->getPost('price_option')),
|
||||
'print_option' => $this->request->getPost('print_option') === null ? PRINT_ALL : intval($this->request->getPost('print_option')),
|
||||
|
||||
@@ -207,7 +207,7 @@ class Items extends Secure_Controller
|
||||
*/
|
||||
public function getSuggestLowSell(): void
|
||||
{
|
||||
$suggestions = $this->item->get_low_sell_suggestions($this->request->getPostGet('name'));
|
||||
$suggestions = $this->item->get_low_sell_suggestions($this->request->getPo1stGet('name'));
|
||||
|
||||
echo json_encode($suggestions);
|
||||
}
|
||||
@@ -1446,7 +1446,7 @@ class Items extends Secure_Controller
|
||||
$attributeId = $attributeValue;
|
||||
break;
|
||||
case DECIMAL:
|
||||
$attributeValue = prepare_decimal($attributeValue);
|
||||
$attributeValue = parse_decimals($attributeValue);
|
||||
//Fall through to save the attribute value
|
||||
default:
|
||||
$attributeId = $this->attribute->saveAttributeValue($attributeValue, $definitionId, $itemId, $attributeIds[$definitionId], $definitionType);
|
||||
|
||||
@@ -211,19 +211,16 @@ class Receivings extends Secure_Controller
|
||||
'discount' => 'trim|permit_empty|decimal_locale',
|
||||
];
|
||||
|
||||
$raw_price = prepare_decimal($this->request->getPost('price'));
|
||||
$raw_quantity = prepare_decimal($this->request->getPost('quantity'));
|
||||
$raw_discount = prepare_decimal($this->request->getPost('discount'));
|
||||
$raw_receiving_quantity = prepare_decimal($this->request->getPost('receiving_quantity'));
|
||||
$price = parse_decimals($this->request->getPost('price'));
|
||||
$quantity = parse_quantity($this->request->getPost('quantity'));
|
||||
$raw_receiving_quantity = parse_quantity($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) ?? '';
|
||||
$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);
|
||||
$discount = $discount_type
|
||||
? parse_quantity(filter_var($raw_discount, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION))
|
||||
: parse_decimals(filter_var($raw_discount, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION));
|
||||
? parse_quantity(filter_var($this->request->getPost('discount'), FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION))
|
||||
: parse_decimals(filter_var($this->request->getPost('discount'), FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION));
|
||||
|
||||
$receiving_quantity = filter_var($raw_receiving_quantity, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
|
||||
|
||||
@@ -327,7 +324,7 @@ class Receivings extends Secure_Controller
|
||||
*/
|
||||
public function postComplete(): void
|
||||
{
|
||||
$amount_tendered = prepare_decimal($this->request->getPost('amount_tendered'));
|
||||
|
||||
$data = [];
|
||||
|
||||
$data['cart'] = $this->receiving_lib->get_cart();
|
||||
@@ -341,7 +338,7 @@ class Receivings extends Secure_Controller
|
||||
$data['stock_location'] = $this->receiving_lib->get_stock_source();
|
||||
if($this->request->getPost('amount_tendered') != null)
|
||||
{
|
||||
$data['amount_tendered'] = filter_var($amount_tendered, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
|
||||
$data['amount_tendered'] = parse_decimals($this->request->getPost('amount_tendered'));
|
||||
$data['amount_change'] = to_currency($data['amount_tendered'] - $data['total']);
|
||||
}
|
||||
|
||||
|
||||
@@ -371,8 +371,8 @@ class Sales extends Secure_Controller
|
||||
*/
|
||||
public function postSetPriceWorkOrders(): void
|
||||
{
|
||||
$price_work_orders = prepare_decimal($this->request->getPost('price_work_orders'));
|
||||
$this->sale_lib->set_price_work_orders(filter_var($price_work_orders, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION));
|
||||
$price_work_orders = parse_decimals($this->request->getPost('price_work_orders'));
|
||||
$this->sale_lib->set_price_work_orders($price_work_orders);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -420,8 +420,8 @@ class Sales extends Secure_Controller
|
||||
if($payment_type === lang('Sales.giftcard'))
|
||||
{
|
||||
//In the case of giftcard payment the register input amount_tendered becomes the giftcard number
|
||||
$amount_tendered = prepare_decimal($this->request->getPost('amount_tendered'));
|
||||
$giftcard_num = filter_var($amount_tendered, FILTER_SANITIZE_FULL_SPECIAL_CHARS, FILTER_FLAG_ALLOW_FRACTION);
|
||||
$amount_tendered = parse_decimals($this->request->getPost('amount_tendered'));
|
||||
$giftcard_num = $amount_tendered;
|
||||
|
||||
$payments = $this->sale_lib->get_payments();
|
||||
$payment_type = $payment_type . ':' . $giftcard_num;
|
||||
@@ -485,8 +485,7 @@ class Sales extends Secure_Controller
|
||||
{
|
||||
$amount_due = $this->sale_lib->get_total();
|
||||
$sales_total = $this->sale_lib->get_total(false);
|
||||
$raw_amount_tendered = prepare_decimal($this->request->getPost('amount_tendered'));
|
||||
$amount_tendered = filter_var($raw_amount_tendered, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
|
||||
$amount_tendered = parse_decimals($this->request->getPost('amount_tendered'));
|
||||
$this->sale_lib->add_payment($payment_type, $amount_tendered);
|
||||
$cash_adjustment_amount = $amount_due - $sales_total;
|
||||
if($cash_adjustment_amount <> 0)
|
||||
@@ -497,8 +496,7 @@ class Sales extends Secure_Controller
|
||||
}
|
||||
else
|
||||
{
|
||||
$raw_amount_tendered = prepare_decimal($this->request->getPost('amount_tendered'));
|
||||
$amount_tendered = filter_var($raw_amount_tendered, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
|
||||
$amount_tendered = parse_decimals($this->request->getPost('amount_tendered'));
|
||||
$this->sale_lib->add_payment($payment_type, $amount_tendered);
|
||||
}
|
||||
}
|
||||
@@ -640,23 +638,18 @@ class Sales extends Secure_Controller
|
||||
|
||||
if($this->validate($rules))
|
||||
{
|
||||
$raw_price = prepare_decimal($this->request->getPost('price'));
|
||||
$raw_quantity = prepare_decimal($this->request->getPost('quantity'));
|
||||
$raw_discount = prepare_decimal($this->request->getPost('discount'));
|
||||
$raw_discounted_total = prepare_decimal($this->request->getPost('discounted_total') ?? '');
|
||||
|
||||
$description = $this->request->getPost('description', 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);
|
||||
$price = parse_decimals($this->request->getPost('price'));
|
||||
$quantity = parse_decimals($this->request->getPost('quantity'));
|
||||
$discount_type = $this->request->getPost('discount_type', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$discount = $discount_type
|
||||
? parse_quantity(filter_var($raw_discount, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION))
|
||||
: parse_decimals(filter_var($raw_discount, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION));
|
||||
? parse_quantity($this->request->getPost('discount'))
|
||||
: parse_decimals($this->request->getPost('discount'));
|
||||
|
||||
$item_location = $this->request->getPost('location', FILTER_SANITIZE_NUMBER_INT);
|
||||
$discounted_total = $this->request->getPost('discounted_total') != ''
|
||||
? filter_var($raw_discounted_total, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION)
|
||||
? parse_decimals($this->request->getPost('discounted_total') ?? '')
|
||||
: null;
|
||||
|
||||
|
||||
@@ -1553,14 +1546,11 @@ class Sales extends Secure_Controller
|
||||
$number_of_payments = $this->request->getPost('number_of_payments', FILTER_SANITIZE_NUMBER_INT);
|
||||
for($i = 0; $i < $number_of_payments; ++$i)
|
||||
{
|
||||
$raw_payment_amount = prepare_decimal($this->request->getPost("payment_amount_$i"));
|
||||
$raw_refund_amount = prepare_decimal($this->request->getPost("refund_amount_$i"));
|
||||
|
||||
$payment_id = $this->request->getPost("payment_id_$i", FILTER_SANITIZE_NUMBER_INT);
|
||||
$payment_type = $this->request->getPost("payment_type_$i", FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$payment_amount = filter_var($raw_payment_amount , FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
|
||||
$payment_amount = parse_decimals($this->request->getPost("payment_amount_$i"));
|
||||
$refund_type = $this->request->getPost("refund_type_$i", FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$cash_refund = filter_var($raw_refund_amount, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
|
||||
$cash_refund = parse_decimals($this->request->getPost("refund_amount_$i"));
|
||||
|
||||
$cash_adjustment = $payment_type == lang('Sales.cash_adjustment') ? CASH_ADJUSTMENT_TRUE : CASH_ADJUSTMENT_FALSE;
|
||||
|
||||
@@ -1594,7 +1584,7 @@ class Sales extends Secure_Controller
|
||||
|
||||
if($payment_type != PAYMENT_TYPE_UNASSIGNED && !empty($payment_amount_new))
|
||||
{
|
||||
$payment_amount = filter_var(prepare_decimal($payment_amount_new), FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
|
||||
$payment_amount = parse_decimals($payment_amount_new);
|
||||
$cash_refund = 0;
|
||||
if($payment_type == lang('Sales.cash_adjustment'))
|
||||
{
|
||||
|
||||
@@ -402,10 +402,8 @@ class Taxes extends Secure_Controller
|
||||
*/
|
||||
public function postSave(int $tax_rate_id = NEW_ENTRY): void
|
||||
{
|
||||
$raw_tax_rate = prepare_decimal($this->request->getPost('tax_rate'));
|
||||
|
||||
$tax_category_id = $this->request->getPost('rate_tax_category_id', FILTER_SANITIZE_NUMBER_INT);
|
||||
$tax_rate = parse_tax(filter_var($raw_tax_rate, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION));
|
||||
$tax_rate = parse_tax($this->request->getPost('tax_rate'));
|
||||
|
||||
if ($tax_rate == 0) //TODO: Replace 0 with constant?
|
||||
{
|
||||
@@ -414,7 +412,7 @@ class Taxes extends Secure_Controller
|
||||
|
||||
$tax_rate_data = [
|
||||
'rate_tax_code_id' => $this->request->getPost('rate_tax_code_id', FILTER_SANITIZE_NUMBER_INT),
|
||||
'rate_tax_category_id' => $this->request->getPost('rate_tax_category_id', FILTER_SANITIZE_NUMBER_INT),
|
||||
'rate_tax_category_id' => $tax_category_id,
|
||||
'rate_jurisdiction_id' => $this->request->getPost('rate_jurisdiction_id', FILTER_SANITIZE_NUMBER_INT),
|
||||
'tax_rate' => $tax_rate,
|
||||
'tax_rounding_code' => $this->request->getPost('tax_rounding_code', FILTER_SANITIZE_NUMBER_INT)
|
||||
|
||||
@@ -703,13 +703,3 @@ function decode_array(array $data): array
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the current locale uses a comma for decimal separator and reformats the decimal to use a period.
|
||||
*
|
||||
* @param string $decimal The decimal to reformat.
|
||||
* @return string The reformatted decimal.
|
||||
*/
|
||||
function prepare_decimal(string $decimal): string
|
||||
{
|
||||
return $decimal;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user