mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-04-11 02:21:10 -04:00
Fixed payment issue in return mode (#1081)
This commit is contained in:
@@ -280,7 +280,6 @@ class Sales extends Secure_Controller
|
||||
}
|
||||
elseif($this->Item_kit->is_valid_item_kit($item_id_or_number_or_item_kit_or_receipt))
|
||||
{
|
||||
|
||||
// Add kit item to order if one is assigned
|
||||
$pieces = explode(' ', $item_id_or_number_or_item_kit_or_receipt);
|
||||
$item_kit_id = $pieces[1];
|
||||
@@ -290,7 +289,7 @@ class Sales extends Secure_Controller
|
||||
$stock_type = $item_kit_info->stock_type;
|
||||
$kit_print_option = $item_kit_info->print_option; // 0-all, 1-priced, 2-kit-only
|
||||
|
||||
if ($item_kit_info->kit_discount_percent != 0 && $item_kit_info->kit_discount_percent > $discount)
|
||||
if($item_kit_info->kit_discount_percent != 0 && $item_kit_info->kit_discount_percent > $discount)
|
||||
{
|
||||
$discount = $item_kit_info->kit_discount_percent;
|
||||
}
|
||||
@@ -298,7 +297,7 @@ class Sales extends Secure_Controller
|
||||
$price = null;
|
||||
$print_option = 0; // Always include in list of items on invoice
|
||||
|
||||
if ($kit_item_id !== '' && $kit_item_id != 0)
|
||||
if(!empty($kit_item_id))
|
||||
{
|
||||
if(!$this->sale_lib->add_item($kit_item_id, $quantity, $item_location, $discount, $price, null, null, null, $print_option))
|
||||
{
|
||||
@@ -310,8 +309,6 @@ class Sales extends Secure_Controller
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Add item kit items to order
|
||||
$stock_warning = null;
|
||||
if(!$this->sale_lib->add_item_kit($item_id_or_number_or_item_kit_or_receipt, $item_location, $discount, $price_option, $kit_print_option, $stock_warning))
|
||||
@@ -322,7 +319,6 @@ class Sales extends Secure_Controller
|
||||
{
|
||||
$data['warning'] = $stock_warning;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -694,7 +690,7 @@ class Sales extends Secure_Controller
|
||||
$data['invoice_number'] = $this->_substitute_invoice_number($customer_info);
|
||||
$data['invoice_number_enabled'] = $this->sale_lib->is_invoice_number_enabled();
|
||||
$data['print_after_sale'] = $this->sale_lib->is_print_after_sale();
|
||||
$data['payments_cover_total'] = $this->sale_lib->get_amount_due() <= 0;
|
||||
$data['payments_cover_total'] = $this->sale_lib->is_payment_covering_total();
|
||||
|
||||
$data = $this->xss_clean($data);
|
||||
|
||||
|
||||
@@ -201,7 +201,15 @@ class Sale_lib
|
||||
$precision = $this->CI->config->item('currency_decimals');
|
||||
$rounded_due = bccomp(round($amount_due, $precision, PHP_ROUND_HALF_EVEN), 0, $precision);
|
||||
// take care of rounding error introduced by round tripping payment amount to the browser
|
||||
return $rounded_due == 0 ? 0 : $amount_due;
|
||||
return $rounded_due == 0 ? 0 : $amount_due;
|
||||
}
|
||||
|
||||
public function is_payment_covering_total()
|
||||
{
|
||||
$amount_due = $this->get_amount_due();
|
||||
// 0 decimal -> 1 / 2 = 0.5, 1 decimals -> 0.1 / 2 = 0.05, 2 decimals -> 0.01 / 2 = 0.005
|
||||
$threshold = bcpow(10, -$this->CI->config->item('currency_decimals')) / 2;
|
||||
return ($amount_due > -$threshold && $amount_due < $threshold);
|
||||
}
|
||||
|
||||
public function get_customer()
|
||||
@@ -301,11 +309,11 @@ class Sale_lib
|
||||
|
||||
public function add_item(&$item_id, $quantity = 1, $item_location, $discount = 0, $price = NULL, $description = NULL, $serialnumber = NULL, $include_deleted = FALSE, $print_option = '0')
|
||||
{
|
||||
|
||||
$item_info = $this->CI->Item->get_info_by_id_or_number($item_id);
|
||||
|
||||
//make sure item exists
|
||||
if (empty($item_info)) {
|
||||
if(empty($item_info))
|
||||
{
|
||||
$item_id = -1;
|
||||
return FALSE;
|
||||
}
|
||||
@@ -332,11 +340,13 @@ class Sale_lib
|
||||
//We primed the loop so maxkey is 0 the first time.
|
||||
//Also, we have stored the key in the element itself so we can compare.
|
||||
|
||||
if ($maxkey <= $item['line']) {
|
||||
if($maxkey <= $item['line'])
|
||||
{
|
||||
$maxkey = $item['line'];
|
||||
}
|
||||
|
||||
if ($item['item_id'] == $item_id && $item['item_location'] == $item_location) {
|
||||
if($item['item_id'] == $item_id && $item['item_location'] == $item_location)
|
||||
{
|
||||
$itemalreadyinsale = TRUE;
|
||||
$updatekey = $item['line'];
|
||||
if(!$item_info->is_serialized)
|
||||
@@ -349,11 +359,11 @@ class Sale_lib
|
||||
$insertkey = $maxkey + 1;
|
||||
//array/cart records are identified by $insertkey and item_id is just another field.
|
||||
|
||||
if (is_null($price))
|
||||
if(is_null($price))
|
||||
{
|
||||
$price = $item_info->unit_price;
|
||||
}
|
||||
elseif ($price == 0)
|
||||
elseif($price == 0)
|
||||
{
|
||||
$price = 0.00;
|
||||
$discount = 0.00;
|
||||
|
||||
@@ -350,55 +350,55 @@ if (isset($success))
|
||||
</table>
|
||||
|
||||
<div id="payment_details">
|
||||
<?php
|
||||
// Show Complete sale button instead of Add Payment if there is no amount due left
|
||||
if($payments_cover_total)
|
||||
{
|
||||
?>
|
||||
<?php echo form_open($controller_name."/add_payment", array('id'=>'add_payment_form', 'class'=>'form-horizontal')); ?>
|
||||
<table class="sales_table_100">
|
||||
<tr>
|
||||
<td><?php echo $this->lang->line('sales_payment');?></td>
|
||||
<td>
|
||||
<?php echo form_dropdown('payment_type', $payment_options, array(), array('id'=>'payment_types', 'class'=>'selectpicker show-menu-arrow', 'data-style'=>'btn-default btn-sm', 'data-width'=>'auto', 'disabled'=>'disabled')); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span id="amount_tendered_label"><?php echo $this->lang->line('sales_amount_tendered'); ?></span></td>
|
||||
<td>
|
||||
<?php echo form_input(array('name'=>'amount_tendered', 'id'=>'amount_tendered', 'class'=>'form-control input-sm disabled', 'disabled'=>'disabled', 'value'=>'0', 'size'=>'5', 'tabindex'=>++$tabindex)); ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php echo form_close(); ?>
|
||||
<?php
|
||||
// Show Complete sale button instead of Add Payment if there is no amount due left
|
||||
if($payments_cover_total)
|
||||
{
|
||||
?>
|
||||
<?php echo form_open($controller_name."/add_payment", array('id'=>'add_payment_form', 'class'=>'form-horizontal')); ?>
|
||||
<table class="sales_table_100">
|
||||
<tr>
|
||||
<td><?php echo $this->lang->line('sales_payment');?></td>
|
||||
<td>
|
||||
<?php echo form_dropdown('payment_type', $payment_options, array(), array('id'=>'payment_types', 'class'=>'selectpicker show-menu-arrow', 'data-style'=>'btn-default btn-sm', 'data-width'=>'auto', 'disabled'=>'disabled')); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span id="amount_tendered_label"><?php echo $this->lang->line('sales_amount_tendered'); ?></span></td>
|
||||
<td>
|
||||
<?php echo form_input(array('name'=>'amount_tendered', 'id'=>'amount_tendered', 'class'=>'form-control input-sm disabled', 'disabled'=>'disabled', 'value'=>'0', 'size'=>'5', 'tabindex'=>++$tabindex)); ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php echo form_close(); ?>
|
||||
|
||||
<div class='btn btn-sm btn-success pull-right' id='finish_sale_button' tabindex='<?php echo ++$tabindex; ?>'><span class="glyphicon glyphicon-ok"> </span><?php echo $this->lang->line('sales_complete_sale'); ?></div>
|
||||
<?php
|
||||
}
|
||||
else
|
||||
{
|
||||
?>
|
||||
<?php echo form_open($controller_name."/add_payment", array('id'=>'add_payment_form', 'class'=>'form-horizontal')); ?>
|
||||
<table class="sales_table_100">
|
||||
<tr>
|
||||
<td><?php echo $this->lang->line('sales_payment');?></td>
|
||||
<td>
|
||||
<?php echo form_dropdown('payment_type', $payment_options, array(), array('id'=>'payment_types', 'class'=>'selectpicker show-menu-arrow', 'data-style'=>'btn-default btn-sm', 'data-width'=>'auto')); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span id="amount_tendered_label"><?php echo $this->lang->line('sales_amount_tendered'); ?></span></td>
|
||||
<td>
|
||||
<?php echo form_input(array('name'=>'amount_tendered', 'id'=>'amount_tendered', 'class'=>'form-control input-sm', 'value'=>to_currency_no_money($amount_due), 'size'=>'5', 'tabindex'=>++$tabindex)); ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php echo form_close(); ?>
|
||||
<div class='btn btn-sm btn-success pull-right' id='finish_sale_button' tabindex='<?php echo ++$tabindex; ?>'><span class="glyphicon glyphicon-ok"> </span><?php echo $this->lang->line('sales_complete_sale'); ?></div>
|
||||
<?php
|
||||
}
|
||||
else
|
||||
{
|
||||
?>
|
||||
<?php echo form_open($controller_name."/add_payment", array('id'=>'add_payment_form', 'class'=>'form-horizontal')); ?>
|
||||
<table class="sales_table_100">
|
||||
<tr>
|
||||
<td><?php echo $this->lang->line('sales_payment');?></td>
|
||||
<td>
|
||||
<?php echo form_dropdown('payment_type', $payment_options, array(), array('id'=>'payment_types', 'class'=>'selectpicker show-menu-arrow', 'data-style'=>'btn-default btn-sm', 'data-width'=>'auto')); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span id="amount_tendered_label"><?php echo $this->lang->line('sales_amount_tendered'); ?></span></td>
|
||||
<td>
|
||||
<?php echo form_input(array('name'=>'amount_tendered', 'id'=>'amount_tendered', 'class'=>'form-control input-sm', 'value'=>to_currency_no_money($amount_due), 'size'=>'5', 'tabindex'=>++$tabindex)); ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php echo form_close(); ?>
|
||||
|
||||
<div class='btn btn-sm btn-success pull-right' id='add_payment_button' tabindex='<?php echo ++$tabindex; ?>'><span class="glyphicon glyphicon-credit-card"> </span><?php echo $this->lang->line('sales_add_payment'); ?></div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<div class='btn btn-sm btn-success pull-right' id='add_payment_button' tabindex='<?php echo ++$tabindex; ?>'><span class="glyphicon glyphicon-credit-card"> </span><?php echo $this->lang->line('sales_add_payment'); ?></div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
// Only show this part if there is at least one payment entered.
|
||||
|
||||
Reference in New Issue
Block a user