mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-05-24 08:20:54 -04:00
Fixed receipt, change due and total cash issues with no payment cases (#707)
This commit is contained in:
@@ -727,7 +727,7 @@ class Sales extends Secure_Controller
|
||||
public function save($sale_id = -1)
|
||||
{
|
||||
$newdate = $this->input->post('date');
|
||||
|
||||
|
||||
$date_formatter = date_create_from_format($this->config->item('dateformat') . ' ' . $this->config->item('timeformat'), $newdate);
|
||||
|
||||
$sale_data = array(
|
||||
@@ -737,7 +737,7 @@ class Sales extends Secure_Controller
|
||||
'comment' => $this->input->post('comment'),
|
||||
'invoice_number' => $this->input->post('invoice_number') != '' ? $this->input->post('invoice_number') : NULL
|
||||
);
|
||||
|
||||
|
||||
// go through all the payment type input from the form, make sure the form matches the name and iterator number
|
||||
$payments = array();
|
||||
$number_of_payments = $this->input->post('number_of_payments');
|
||||
@@ -769,7 +769,7 @@ class Sales extends Secure_Controller
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($this->Sale->update($sale_id, $sale_data, $payments))
|
||||
{
|
||||
echo json_encode(array('success' => TRUE, 'message' => $this->lang->line('sales_successfully_updated'), 'id' => $sale_id));
|
||||
@@ -786,7 +786,7 @@ class Sales extends Secure_Controller
|
||||
|
||||
$this->_reload();
|
||||
}
|
||||
|
||||
|
||||
public function suspend()
|
||||
{
|
||||
$cart = $this->sale_lib->get_cart();
|
||||
|
||||
@@ -36,6 +36,13 @@ function to_currency_no_money($number)
|
||||
|
||||
function to_tax_decimals($number)
|
||||
{
|
||||
// taxes that are NULL, '' or 0 don't need to be displayed
|
||||
// NOTE: do not remove this line otherwise the items edit form will show a tax with 0 and it will save it
|
||||
if(empty($number))
|
||||
{
|
||||
return $number;
|
||||
}
|
||||
|
||||
return to_decimals($number, 'tax_decimals');
|
||||
}
|
||||
|
||||
@@ -47,7 +54,8 @@ function to_quantity_decimals($number)
|
||||
function to_decimals($number, $decimals, $type=\NumberFormatter::DECIMAL)
|
||||
{
|
||||
// ignore empty strings and return
|
||||
if(empty($number))
|
||||
// NOTE: do not change it to empty because otherwise tables will show a 0 with no decimal nor currency symbol
|
||||
if(!isset($number))
|
||||
{
|
||||
return $number;
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ Get the sales payments summary
|
||||
function get_sales_manage_payments_summary($payments, $sales, $controller)
|
||||
{
|
||||
$CI =& get_instance();
|
||||
$table='<div id="report_summary">';
|
||||
$table = '<div id="report_summary">';
|
||||
|
||||
foreach($payments as $key=>$payment)
|
||||
{
|
||||
@@ -104,9 +104,9 @@ function get_sales_manage_payments_summary($payments, $sales, $controller)
|
||||
$amount -= $sale['change_due'];
|
||||
}
|
||||
}
|
||||
$table.='<div class="summary_row">'.$payment['payment_type'].': '.to_currency( $amount ) . '</div>';
|
||||
$table .= '<div class="summary_row">' . $payment['payment_type'] . ': ' . to_currency( $amount ) . '</div>';
|
||||
}
|
||||
$table.='</div>';
|
||||
$table .= '</div>';
|
||||
|
||||
return $table;
|
||||
}
|
||||
|
||||
@@ -188,7 +188,7 @@ class Sale_lib
|
||||
{
|
||||
$payment_total = $this->get_payments_total();
|
||||
$sales_total = $this->get_total();
|
||||
|
||||
|
||||
return bcsub($sales_total, $payment_total, PRECISION);
|
||||
}
|
||||
|
||||
@@ -553,7 +553,7 @@ class Sale_lib
|
||||
$customer = $this->CI->Customer->get_info($customer_id);
|
||||
|
||||
//Do not charge sales tax if we have a customer that is not taxable
|
||||
return $customer->taxable or $customer_id==-1;
|
||||
return $customer->taxable or $customer_id == -1;
|
||||
}
|
||||
|
||||
public function get_taxes()
|
||||
|
||||
@@ -4,7 +4,7 @@ class Sale extends CI_Model
|
||||
public function get_info($sale_id)
|
||||
{
|
||||
$this->db->select('customer_id, customer_name, customer_first_name AS first_name, customer_last_name AS last_name, customer_email AS email, customer_comments AS comments,
|
||||
sale_payment_amount AS amount_tendered, (sale_payment_amount - total) AS change_due, total AS amount_due, payment_type,
|
||||
sale_payment_amount AS amount_tendered, SUM(total) AS amount_due, (sale_payment_amount - SUM(total)) AS change_due, payment_type,
|
||||
sale_id, sale_date, sale_time, comment, invoice_number, employee_id');
|
||||
$this->db->from('sales_items_temp');
|
||||
|
||||
@@ -14,7 +14,7 @@ class Sale extends CI_Model
|
||||
|
||||
return $this->db->get();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Get number of rows for the takings (sales/manage) view
|
||||
*/
|
||||
@@ -76,7 +76,10 @@ class Sale extends CI_Model
|
||||
|
||||
if($filters['only_cash'] != FALSE)
|
||||
{
|
||||
$this->db->like('payment_type ', $this->lang->line('sales_cash'), 'after');
|
||||
$this->db->group_start();
|
||||
$this->db->like('payment_type', $this->lang->line('sales_cash'), 'after');
|
||||
$this->db->or_where('payment_type IS NULL');
|
||||
$this->db->group_end();
|
||||
}
|
||||
|
||||
$this->db->group_by('sale_id');
|
||||
@@ -136,7 +139,7 @@ class Sale extends CI_Model
|
||||
|
||||
if($filters['only_cash'] != FALSE)
|
||||
{
|
||||
$this->db->like('payment_type ', $this->lang->line('sales_cash'), 'after');
|
||||
$this->db->like('payment_type', $this->lang->line('sales_cash'), 'after');
|
||||
}
|
||||
|
||||
$this->db->group_by('payment_type');
|
||||
@@ -215,7 +218,7 @@ class Sale extends CI_Model
|
||||
|
||||
return $this->db->count_all_results();
|
||||
}
|
||||
|
||||
|
||||
public function get_sale_by_invoice_number($invoice_number)
|
||||
{
|
||||
$this->db->from('sales');
|
||||
@@ -223,7 +226,7 @@ class Sale extends CI_Model
|
||||
|
||||
return $this->db->get();
|
||||
}
|
||||
|
||||
|
||||
public function get_invoice_number_for_year($year = '', $start_from = 0)
|
||||
{
|
||||
$year = $year == '' ? date('Y') : $year;
|
||||
@@ -243,7 +246,7 @@ class Sale extends CI_Model
|
||||
|
||||
return ($this->db->get()->num_rows()==1);
|
||||
}
|
||||
|
||||
|
||||
public function update($sale_id, $sale_data, $payments)
|
||||
{
|
||||
$this->db->where('sale_id', $sale_id);
|
||||
@@ -277,7 +280,7 @@ class Sale extends CI_Model
|
||||
|
||||
return $success;
|
||||
}
|
||||
|
||||
|
||||
public function save($items, $customer_id, $employee_id, $comment, $invoice_number, $payments, $sale_id = FALSE)
|
||||
{
|
||||
if(count($items) == 0)
|
||||
@@ -349,7 +352,7 @@ class Sale extends CI_Model
|
||||
}
|
||||
|
||||
// Inventory Count Details
|
||||
$sale_remarks ='POS '.$sale_id;
|
||||
$sale_remarks = 'POS '.$sale_id;
|
||||
$inv_data = array(
|
||||
'trans_date' => date('Y-m-d H:i:s'),
|
||||
'trans_items' => $item['item_id'],
|
||||
@@ -385,7 +388,7 @@ class Sale extends CI_Model
|
||||
|
||||
return $sale_id;
|
||||
}
|
||||
|
||||
|
||||
public function delete_list($sale_ids, $employee_id, $update_inventory = TRUE)
|
||||
{
|
||||
$result = TRUE;
|
||||
@@ -397,7 +400,7 @@ class Sale extends CI_Model
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
public function delete($sale_id, $employee_id, $update_inventory = TRUE)
|
||||
{
|
||||
// start a transaction to assure data integrity
|
||||
@@ -458,7 +461,7 @@ class Sale extends CI_Model
|
||||
|
||||
return $this->db->get();
|
||||
}
|
||||
|
||||
|
||||
public function get_payment_options($giftcard = TRUE)
|
||||
{
|
||||
$payments = array();
|
||||
@@ -499,7 +502,7 @@ class Sale extends CI_Model
|
||||
|
||||
return $this->Customer->get_info($this->db->get()->row()->customer_id);
|
||||
}
|
||||
|
||||
|
||||
public function invoice_number_exists($invoice_number, $sale_id = '')
|
||||
{
|
||||
$this->db->from('sales');
|
||||
@@ -511,7 +514,7 @@ class Sale extends CI_Model
|
||||
|
||||
return ($this->db->get()->num_rows() == 1);
|
||||
}
|
||||
|
||||
|
||||
public function get_giftcard_value($giftcardNumber)
|
||||
{
|
||||
if(!$this->Giftcard->exists($this->Giftcard->get_giftcard_id($giftcardNumber)))
|
||||
@@ -576,7 +579,7 @@ class Sale extends CI_Model
|
||||
sales_items.item_location,
|
||||
sales_items.description,
|
||||
payments.payment_type,
|
||||
payments.sale_payment_amount,
|
||||
IFNULL(payments.sale_payment_amount, 0) AS sale_payment_amount,
|
||||
SUM(sales_items_taxes.percent) AS item_tax_percent,
|
||||
' . "
|
||||
ROUND($sale_total * $total, $decimals) AS total,
|
||||
@@ -592,8 +595,8 @@ class Sale extends CI_Model
|
||||
ON sales_items.item_id = items.item_id
|
||||
LEFT OUTER JOIN (
|
||||
SELECT sale_id,
|
||||
SUM(payment_amount) AS sale_payment_amount,
|
||||
GROUP_CONCAT(CONCAT(payment_type, " ", payment_amount) SEPARATOR ", ") AS payment_type
|
||||
SUM(payment_amount) AS sale_payment_amount,
|
||||
GROUP_CONCAT(CONCAT(payment_type, " ", payment_amount) SEPARATOR ", ") AS payment_type
|
||||
FROM ' . $this->db->dbprefix('sales_payments') . '
|
||||
GROUP BY sale_id
|
||||
) AS payments
|
||||
|
||||
@@ -143,12 +143,12 @@
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
$only_sale_check = TRUE;
|
||||
$only_sale_check = FALSE;
|
||||
$show_giftcard_remainder = FALSE;
|
||||
foreach($payments as $payment_id=>$payment)
|
||||
{
|
||||
$only_sale_check &= $payment['payment_type'] == $this->lang->line('sales_check');
|
||||
$splitpayment=explode(':',$payment['payment_type']);
|
||||
$only_sale_check |= $payment['payment_type'] == $this->lang->line('sales_check');
|
||||
$splitpayment = explode(':', $payment['payment_type']);
|
||||
$show_giftcard_remainder |= $splitpayment[0] == $this->lang->line('sales_giftcard');
|
||||
?>
|
||||
<tr>
|
||||
|
||||
@@ -138,12 +138,12 @@
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
$only_sale_check = TRUE;
|
||||
$only_sale_check = FALSE;
|
||||
$show_giftcard_remainder = FALSE;
|
||||
foreach($payments as $payment_id=>$payment)
|
||||
{
|
||||
$only_sale_check &= $payment['payment_type'] == $this->lang->line('sales_check');
|
||||
$splitpayment=explode(':',$payment['payment_type']);
|
||||
$only_sale_check |= $payment['payment_type'] == $this->lang->line('sales_check');
|
||||
$splitpayment = explode(':', $payment['payment_type']);
|
||||
$show_giftcard_remainder |= $splitpayment[0] == $this->lang->line('sales_giftcard');
|
||||
?>
|
||||
<tr>
|
||||
|
||||
@@ -141,12 +141,12 @@
|
||||
|
||||
|
||||
<?php
|
||||
$only_sale_check = TRUE;
|
||||
$only_sale_check = FALSE;
|
||||
$show_giftcard_remainder = FALSE;
|
||||
foreach($payments as $payment_id=>$payment)
|
||||
{
|
||||
$only_sale_check &= $payment['payment_type'] == $this->lang->line('sales_check');
|
||||
$splitpayment=explode(':',$payment['payment_type']);
|
||||
$only_sale_check |= $payment['payment_type'] == $this->lang->line('sales_check');
|
||||
$splitpayment = explode(':', $payment['payment_type']);
|
||||
$show_giftcard_remainder |= $splitpayment[0] == $this->lang->line('sales_giftcard');
|
||||
?>
|
||||
<tr>
|
||||
|
||||
Reference in New Issue
Block a user