Skip to content

Commit

Permalink
Fix payment issue (#1182) regen sql script files
Browse files Browse the repository at this point in the history
  • Loading branch information
daN4cat committed Mar 12, 2017
1 parent 55350b8 commit 3f489d6
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 16 deletions.
29 changes: 20 additions & 9 deletions application/libraries/Sale_lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ public function get_cart()

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;
Expand All @@ -58,7 +58,8 @@ public function sort_and_filter_cart($cart)
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);
Expand All @@ -67,7 +68,8 @@ public function sort_and_filter_cart($cart)
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'];
Expand All @@ -78,7 +80,8 @@ public function sort_and_filter_cart($cart)
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'];
Expand All @@ -89,7 +92,8 @@ public function sort_and_filter_cart($cart)
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);
Expand Down Expand Up @@ -316,10 +320,17 @@ public function get_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);

if($this->get_mode() == 'return')
{
return ($this->get_amount_due() > -$threshold);
}
else
{
return ($this->get_amount_due() < $threshold);
}
}

public function get_customer()
Expand Down
2 changes: 1 addition & 1 deletion application/views/partial/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -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; ?>

Expand Down
48 changes: 47 additions & 1 deletion database/database.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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','');


-- --------------------------------------------------------
Expand All @@ -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`)
Expand Down Expand Up @@ -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
Expand Down
57 changes: 53 additions & 4 deletions database/migrate_phppos_dist.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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', ''),
Expand Down Expand Up @@ -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'),
Expand Down Expand Up @@ -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','');


-- --------------------------------------------------------
Expand All @@ -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`)
Expand Down Expand Up @@ -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 ;

--
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
--
Expand Down
2 changes: 1 addition & 1 deletion public/dist/opensourcepos.min.js

Large diffs are not rendered by default.

0 comments on commit 3f489d6

Please sign in to comment.