Fix payment issue (#1182) regen sql script files

This commit is contained in:
FrancescoUK
2017-03-12 21:32:48 +00:00
parent 55350b8bf8
commit 3f489d6f53
5 changed files with 122 additions and 16 deletions

View File

@@ -39,15 +39,15 @@ class Sale_lib
public function sort_and_filter_cart($cart)
{
if (empty($cart))
if(empty($cart))
{
return $cart;
}
$filtered_cart = array();
foreach($cart as $k=>$v) {
foreach($cart as $k=>$v)
{
if($v['print_option'] == '0')
{
$filtered_cart[] = $v;
@@ -58,7 +58,8 @@ class Sale_lib
if($this->CI->config->item('line_sequence') == '0')
{
$sort = array();
foreach($filtered_cart as $k=>$v) {
foreach($filtered_cart as $k=>$v)
{
$sort['line'][$k] = $v['line'];
}
array_multisort($sort['line'], SORT_ASC, $filtered_cart);
@@ -67,7 +68,8 @@ class Sale_lib
elseif($this->CI->config->item('line_sequence') == '1')
{
$sort = array();
foreach($filtered_cart as $k=>$v) {
foreach($filtered_cart as $k=>$v)
{
$sort['stock_type'][$k] = $v['stock_type'];
$sort['description'][$k] = $v['description'];
$sort['name'][$k] = $v['name'];
@@ -78,7 +80,8 @@ class Sale_lib
elseif($this->CI->config->item('line_sequence') == '2')
{
$sort = array();
foreach($filtered_cart as $k=>$v) {
foreach($filtered_cart as $k=>$v)
{
$sort['category'][$k] = $v['stock_type'];
$sort['description'][$k] = $v['description'];
$sort['name'][$k] = $v['name'];
@@ -89,7 +92,8 @@ class Sale_lib
else
{
$sort = array();
foreach($filtered_cart as $k=>$v) {
foreach($filtered_cart as $k=>$v)
{
$sort['line'][$k] = $v['line'];
}
array_multisort($sort['line'], SORT_ASC, $filtered_cart);
@@ -316,10 +320,17 @@ class Sale_lib
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);
if($this->get_mode() == 'return')
{
return ($this->get_amount_due() > -$threshold);
}
else
{
return ($this->get_amount_due() < $threshold);
}
}
public function get_customer()

View File

@@ -74,7 +74,7 @@
<link rel="stylesheet" type="text/css" href="dist/style.css"/>
<!-- end mincss template tags -->
<!-- start minjs template tags -->
<script type="text/javascript" src="dist/opensourcepos.min.js?rel=3af1006480"></script>
<script type="text/javascript" src="dist/opensourcepos.min.js?rel=7e9664c539"></script>
<!-- end minjs template tags -->
<?php endif; ?>

View File

@@ -88,7 +88,8 @@ INSERT INTO `ospos_app_config` (`key`, `value`) VALUES
('statistics', '1'),
('language', 'english'),
('language_code', 'en'),
('date_or_time_format','');
('date_or_time_format',''),
('customer_reward_enable','');
-- --------------------------------------------------------
@@ -103,6 +104,8 @@ CREATE TABLE `ospos_customers` (
`account_number` varchar(255) DEFAULT NULL,
`taxable` int(1) NOT NULL DEFAULT '1',
`discount_percent` decimal(15,2) NOT NULL DEFAULT '0',
`package_id` int(11) DEFAULT NULL,
`points` int(11) DEFAULT NULL,
`deleted` int(1) NOT NULL DEFAULT '0',
UNIQUE KEY `account_number` (`account_number`),
KEY `person_id` (`person_id`)
@@ -774,6 +777,49 @@ INSERT INTO `ospos_dinner_tables` (`dinner_table_id`, `name`, `status`, `deleted
(1, 'Delivery', 0, 0),
(2, 'Take Away', 0, 0);
--
-- Table structure for table `ospos_customer_packages`
--
CREATE TABLE IF NOT EXISTS `ospos_customers_packages` (
`package_id` int(11) NOT NULL AUTO_INCREMENT,
`package_name` varchar(255) DEFAULT NULL,
`points_percent` float NOT NULL DEFAULT '0',
`deleted` int(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`package_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
INSERT INTO `ospos_customers_packages` (`package_id`, `package_name`, `points_percent`, `deleted`) VALUES
(1, 'Default', 0, 0),
(2, 'Bronze', 10, 0),
(3, 'Silver', 20, 0),
(4, 'Gold', 30, 0),
(5, 'Premium', 50, 0);
--
-- Table structure for table `ospos_customer_points`
--
CREATE TABLE IF NOT EXISTS `ospos_customers_points` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`person_id` int(11) NOT NULL,
`package_id` int(11) NOT NULL,
`sale_id` int(11) NOT NULL,
`points_earned` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
--
-- Table structure for table `ospos_sales_reward_points`
--
CREATE TABLE IF NOT EXISTS `ospos_sales_reward_points` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`sale_id` int(11) NOT NULL,
`earned` float NOT NULL,
`used` float NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
--
-- Constraints for dumped tables

View File

@@ -16,6 +16,7 @@ CREATE TABLE `ospos_app_config` (
INSERT INTO `ospos_app_config` (`key`, `value`) VALUES
('address', '123 Nowhere street'),
('company', 'Open Source Point of Sale'),
('default_register_mode', 'sale'),
('default_tax_rate', '8'),
('email', 'changeme@example.com'),
('fax', ''),
@@ -44,9 +45,12 @@ INSERT INTO `ospos_app_config` (`key`, `value`) VALUES
('receipt_show_description', '1'),
('receipt_show_serialnumber', '1'),
('invoice_enable', '1'),
('last_used_invoice_number', '0'),
('last_used_quote_number', '0'),
('line_sequence', '0'),
('recv_invoice_format', '$CO'),
('sales_invoice_format', '$CO'),
('sales_quote_format', 'Q%y{QSEQ:6}'),
('invoice_email_message', 'Dear $CU, In attachment the receipt for sale $INV'),
('invoice_default_comments', 'This is a default comment'),
('print_silently', '1'),
@@ -84,7 +88,8 @@ INSERT INTO `ospos_app_config` (`key`, `value`) VALUES
('statistics', '1'),
('language', 'english'),
('language_code', 'en'),
('date_or_time_format','');
('date_or_time_format',''),
('customer_reward_enable','');
-- --------------------------------------------------------
@@ -99,6 +104,8 @@ CREATE TABLE `ospos_customers` (
`account_number` varchar(255) DEFAULT NULL,
`taxable` int(1) NOT NULL DEFAULT '1',
`discount_percent` decimal(15,2) NOT NULL DEFAULT '0',
`package_id` int(11) DEFAULT NULL,
`points` int(11) DEFAULT NULL,
`deleted` int(1) NOT NULL DEFAULT '0',
UNIQUE KEY `account_number` (`account_number`),
KEY `person_id` (`person_id`)
@@ -610,12 +617,13 @@ CREATE TABLE `ospos_sales_suspended` (
`employee_id` int(10) NOT NULL DEFAULT '0',
`comment` text NOT NULL,
`invoice_number` varchar(32) DEFAULT NULL,
`quote_number` varchar(32) DEFAULT NULL,
`sale_id` int(10) NOT NULL AUTO_INCREMENT,
`dinner_table_id` int(11) NULL,
PRIMARY KEY (`sale_id`),
KEY `customer_id` (`customer_id`),
KEY `employee_id` (`employee_id`),
KEY `dinner_table_id` (`dinner_table_id`),
KEY `dinner_table_id` (`dinner_table_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
--
@@ -769,6 +777,49 @@ INSERT INTO `ospos_dinner_tables` (`dinner_table_id`, `name`, `status`, `deleted
(1, 'Delivery', 0, 0),
(2, 'Take Away', 0, 0);
--
-- Table structure for table `ospos_customer_packages`
--
CREATE TABLE IF NOT EXISTS `ospos_customers_packages` (
`package_id` int(11) NOT NULL AUTO_INCREMENT,
`package_name` varchar(255) DEFAULT NULL,
`points_percent` float NOT NULL DEFAULT '0',
`deleted` int(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`package_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
INSERT INTO `ospos_customers_packages` (`package_id`, `package_name`, `points_percent`, `deleted`) VALUES
(1, 'Default', 0, 0),
(2, 'Bronze', 10, 0),
(3, 'Silver', 20, 0),
(4, 'Gold', 30, 0),
(5, 'Premium', 50, 0);
--
-- Table structure for table `ospos_customer_points`
--
CREATE TABLE IF NOT EXISTS `ospos_customers_points` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`person_id` int(11) NOT NULL,
`package_id` int(11) NOT NULL,
`sale_id` int(11) NOT NULL,
`points_earned` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
--
-- Table structure for table `ospos_sales_reward_points`
--
CREATE TABLE IF NOT EXISTS `ospos_sales_reward_points` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`sale_id` int(11) NOT NULL,
`earned` float NOT NULL,
`used` float NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
--
-- This migration script should be run after creating tables with the regular database script and before applying the constraints.
@@ -941,8 +992,6 @@ SELECT `person_id`, `company_name`, `account_number`, `deleted` FROM `phppos`.ph
INSERT INTO `ospos_dinner_tables` (`dinner_table_id`, `name`, `status`, `deleted`)
SELECT `dinner_table_id`, `name`, `status`, `deleted` FROM `phppos`.phppos_dinner_tables;
--
-- Constraints for dumped tables
--

View File

File diff suppressed because one or more lines are too long