* Ver. 2.0.2

+ Fixed multiple giftcards issue per Bug #4 reported on Sourceforge where a
  second giftcard added would have its balance set to $0 even if the sale did
  not require the total of the second giftcard to pay the remaining amount due.
+ Small code cleanup

git-svn-id: svn+ssh://jekkos@svn.code.sf.net/p/opensourcepos/code/@58 c3eb156b-1dc0-44e1-88ae-e38439141b53
This commit is contained in:
pappastech
2013-03-05 03:09:38 +00:00
parent 70c172f7bb
commit a8dfa2dbe8
6 changed files with 43 additions and 36 deletions

View File

@@ -1,2 +1,8 @@
* Ver. 2.0.2
+ Fixed multiple giftcards issue per Bug #4 reported on Sourceforge where a
second giftcard added would have its balance set to $0 even if the sale did
not require the total of the second giftcard to pay the remaining amount due.
+ Small code cleanup
-------------------------------------------------------------------------------
* Upgrade to CodeIgniter 2.1.0
* Various small improvements

View File

@@ -9,7 +9,7 @@
|
|
*/
$config['application_version'] = '2.0.1';
$config['application_version'] = '2.0.2';
/*
|--------------------------------------------------------------------------

View File

@@ -53,42 +53,43 @@ class Sales extends Secure_area
//Alain Multiple Payments
function add_payment()
{
$data=array();
$this->form_validation->set_rules('amount_tendered', 'lang:sales_amount_tendered', 'numeric');
$data = array();
$this->form_validation->set_rules( 'amount_tendered', 'lang:sales_amount_tendered', 'numeric' );
if ($this->form_validation->run() == FALSE)
if ( $this->form_validation->run() == FALSE )
{
if ( $this->input->post('payment_type') == $this->lang->line('sales_gift_card') )
if ( $this->input->post( 'payment_type' ) == $this->lang->line( 'sales_gift_card' ) )
$data['error']=$this->lang->line('sales_must_enter_numeric_giftcard');
else
$data['error']=$this->lang->line('sales_must_enter_numeric');
$this->_reload($data);
$this->_reload( $data );
return;
}
$payment_type=$this->input->post('payment_type');
if ( $payment_type == $this->lang->line('sales_giftcard') )
$payment_type = $this->input->post( 'payment_type' );
if ( $payment_type == $this->lang->line( 'sales_giftcard' ) )
{
$payments = $this->sale_lib->get_payments();
$payment_type=$this->input->post('payment_type').':'.$payment_amount=$this->input->post('amount_tendered');
$current_payments_with_giftcard = isset($payments[$payment_type]) ? $payments[$payment_type]['payment_amount'] : 0;
$cur_giftcard_value = $this->Giftcard->get_giftcard_value( $this->input->post('amount_tendered') ) - $current_payments_with_giftcard;
$payment_type = $this->input->post( 'payment_type' ) . ':' . $payment_amount = $this->input->post( 'amount_tendered' );
$current_payments_with_giftcard = isset( $payments[$payment_type] ) ? $payments[$payment_type]['payment_amount'] : 0;
$cur_giftcard_value = $this->Giftcard->get_giftcard_value( $this->input->post( 'amount_tendered' ) ) - $current_payments_with_giftcard;
if ( $cur_giftcard_value <= 0 )
{
$data['error']='Giftcard balance is '.to_currency( $this->Giftcard->get_giftcard_value( $this->input->post('amount_tendered') ) ).' !';
$this->_reload($data);
$data['error'] = 'Giftcard balance is ' . to_currency( $this->Giftcard->get_giftcard_value( $this->input->post( 'amount_tendered' ) ) ) . ' !';
$this->_reload( $data );
return;
}
elseif ( ( $this->Giftcard->get_giftcard_value( $this->input->post('amount_tendered') ) - $this->sale_lib->get_total() ) > 0 )
{
$data['warning']='Giftcard balance is '.to_currency( $this->Giftcard->get_giftcard_value( $this->input->post('amount_tendered') ) - $this->sale_lib->get_total() ).' !';
}
$payment_amount=min( $this->sale_lib->get_total(), $this->Giftcard->get_giftcard_value( $this->input->post('amount_tendered') ) );
$new_giftcard_value = $this->Giftcard->get_giftcard_value( $this->input->post( 'amount_tendered' ) ) - $this->sale_lib->get_amount_due( );
$new_giftcard_value = ( $new_giftcard_value >= 0 ) ? $new_giftcard_value : 0;
$data['warning'] = 'Giftcard ' . $this->input->post( 'amount_tendered' ) . ' balance is ' . to_currency( $new_giftcard_value ) . ' !';
$payment_amount = min( $this->sale_lib->get_amount_due( ), $this->Giftcard->get_giftcard_value( $this->input->post( 'amount_tendered' ) ) );
}
else
{
$payment_amount=$this->input->post('amount_tendered');
$payment_amount = $this->input->post( 'amount_tendered' );
}
if( !$this->sale_lib->add_payment( $payment_type, $payment_amount ) )

View File

@@ -3,12 +3,12 @@
function load_config()
{
$CI =& get_instance();
foreach($CI->Appconfig->get_all()->result() as $app_config)
foreach( $CI->Appconfig->get_all()->result() as $app_config )
{
$CI->config->set_item($app_config->key,$app_config->value);
$CI->config->set_item( $app_config->key, $app_config->value );
}
if ($CI->config->item('language'))
if ( $CI->config->item( 'language' ) )
{
$CI->config->set_item( 'language', $CI->config->item( 'language' ) );
$loaded = $CI->lang->is_loaded;
@@ -20,13 +20,13 @@ function load_config()
}
}
if ($CI->config->item('timezone'))
if ( $CI->config->item( 'timezone' ) )
{
date_default_timezone_set($CI->config->item('timezone'));
date_default_timezone_set( $CI->config->item( 'timezone' ) );
}
else
{
date_default_timezone_set('America/New_York');
date_default_timezone_set( 'America/New_York' );
}
}
?>

View File

@@ -66,28 +66,28 @@ class Sale_lib
$this->CI->session->unset_userdata('email_receipt');
}
function add_payment($payment_id,$payment_amount)
function add_payment( $payment_id, $payment_amount )
{
$payments=$this->get_payments();
$payment = array($payment_id=>
$payments = $this->get_payments();
$payment = array( $payment_id=>
array(
'payment_type'=>$payment_id,
'payment_amount'=>$payment_amount
'payment_type' => $payment_id,
'payment_amount' => $payment_amount
)
);
//payment_method already exists, add to payment_amount
if(isset($payments[$payment_id]))
if( isset( $payments[$payment_id] ) )
{
$payments[$payment_id]['payment_amount']+=$payment_amount;
$payments[$payment_id]['payment_amount'] += $payment_amount;
}
else
{
//add to existing array
$payments+=$payment;
$payments += $payment;
}
$this->set_payments($payments);
$this->set_payments( $payments );
return true;
}
@@ -484,7 +484,7 @@ class Sale_lib
$total = 0;
foreach($this->get_cart() as $item)
{
$total+=($item['price']*$item['quantity']-$item['price']*$item['quantity']*$item['discount']/100);
$total += ( $item['price'] * $item['quantity'] - $item['price'] * $item['quantity'] * $item['discount'] / 100);
}
foreach($this->get_taxes() as $tax)

View File

@@ -9,7 +9,7 @@ $this->load->view("partial/header");
swfobject.embedSWF(
"<?php echo base_url(); ?>open-flash-chart.swf", "chart",
"800", "400", "9.0.0", "expressInstall.swf",
{"data-file":"<?php echo $data_file; ?>"} )
{"data-file":"<?php echo $data_file; ?>"} );
</script>
<?php
?>