diff --git a/.travis.yml b/.travis.yml index 6158f70ac..94d0f227a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,16 @@ sudo: false - + language: node_js +node_js: + - "4.1" + services: - docker before_install: - docker build -t jekkos/opensourcepos . - - docker run -d -p 127.0.0.1:80:80 jekkos/opensourcepos - - sleep 4 + - docker run -d jekkos/opensourcepos script: - - docker exec -t -i $(docker ps | tail -n 1 | cut -d' ' -f1) /bin/sh -c "cd /app; grunt mochaWebdriver:test" + - docker exec -t -i $(docker ps | tail -n 1 | cut -d' ' -f1) /bin/sh -c "while ! curl http://localhost/index.php | grep username; do sleep 1; done; cd app && grunt mochaWebdriver:test" diff --git a/Dockerfile b/Dockerfile index 89e010c03..5578caddf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,9 @@ -FROM ubuntu:trusty +FROM ubuntu:utopic MAINTAINER jekkos +RUN sed -i -e 's/archive.ubuntu.com\|security.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list RUN apt-get update RUN apt-get -y upgrade -RUN DEBIAN_FRONTEND=noninteractive apt-get -y install mysql-client mysql-server apache2 libapache2-mod-php5 pwgen python-setuptools vim-tiny php5-mysql php5-gd nodejs npm +RUN DEBIAN_FRONTEND=noninteractive apt-get -y install mysql-client mysql-server apache2 libapache2-mod-php5 pwgen python-setuptools vim-tiny php5-mysql php5-gd nodejs npm curl RUN easy_install supervisor ADD ./docker/foreground.sh /etc/apache2/foreground.sh ADD ./docker/supervisord.conf /etc/supervisord.conf @@ -20,7 +21,6 @@ RUN npm install -g grunt-cli RUn ln -s /usr/local/bin/grunt /usr/bin/grunt RUN ln -fs /app/* /var/www/html -RUN rm /var/www/html/index.html ADD ./docker/start_container.sh /start_container.sh RUN chmod 755 /start_container.sh EXPOSE 80 3306 diff --git a/application/controllers/Customers.php b/application/controllers/Customers.php index c1d155a76..201a1d3fd 100644 --- a/application/controllers/Customers.php +++ b/application/controllers/Customers.php @@ -73,7 +73,7 @@ class Customers extends Person_controller ); $customer_data=array( 'account_number'=>$this->input->post('account_number') == '' ? null : $this->input->post('account_number'), - 'company_name'=>$this->input->post('company_name') == '' ? null : $this->input->post('account_number'), + 'company_name'=>$this->input->post('company_name') == '' ? null : $this->input->post('company_name'), 'taxable'=>$this->input->post('taxable') != null ); if($this->Customer->save_customer($person_data,$customer_data,$customer_id)) diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php index e573d4285..9a0db9664 100644 --- a/system/libraries/Pagination.php +++ b/system/libraries/Pagination.php @@ -512,14 +512,16 @@ class CI_Pagination { { $this->cur_page = str_replace(array($this->prefix, $this->suffix), '', $this->cur_page); } - } + } else { + $this->cur_page = (string) $this->cur_page; + } // If something isn't quite right, back to the default base page. if ( ! ctype_digit($this->cur_page) OR ($this->use_page_numbers && (int) $this->cur_page === 0)) { $this->cur_page = $base_page; } - else + elseif (empty($this->cur_page)) { // Make sure we're using integers for comparisons later. $this->cur_page = (int) $this->cur_page; diff --git a/test/make_sale_receiving.js b/test/make_sale_receiving.js index 1a3c4471b..ff4d0d59c 100644 --- a/test/make_sale_receiving.js +++ b/test/make_sale_receiving.js @@ -4,26 +4,23 @@ var ospos = require('./ospos'); describe("create item and make sale", function () { this.timeout(25000); + var def_timeout = 3000; + + var item = {name: "anItem", category: "aCategory", cost_price: 10, unit_price: 20}; + it("should be able to add item", function (done) { - return this.browser.get(ospos.url("/index.php/items")).elementByCssSelector("a[title='New Item']", 5000).click() - .waitForElementByName("name", 10000).type("anItem").elementById("category").type("aCategory") - .elementById('cost_price', 2000).clear().type("10").elementById("unit_price", 2000).type("20") - .elementById('tax_name_1', 2000).type('VAT').elementById("tax_percent_name_1", 2000).type("21") - .elementById("1_quantity", 2000).type("1").elementById("reorder_level", 2000).type("0").elementById("submit", 2000).click() - .waitForElementByXPath("//table/tbody/tr[td/text()='anItem']/td[3]").text().then(function (value) { - assert.equal(value, "anItem", "item could not be created!!"); - }).then(done, done); + return ospos.create_item(this.browser, item).then(done, done); }); it("should be able to make sale", function(done) { return this.browser.get(ospos.url("/index.php/sales")) - .elementById("item", 3000).type("1\r\n") - .waitForElementByName("quantity", 5000).clear().type("2").elementByName("discount", 1000).type("10").elementByName("edit_item").click() - .elementById("add_payment_button", 2000).click().elementByCssSelector("tbody#payment_contents tr td:last-child", 5000).text().then(function(value) { + .elementById("item", def_timeout).type("1\r\n") + .waitForElementByName("quantity", def_timeout).clear().type("2").elementByName("discount", def_timeout).type(item.cost_price).elementByName("edit_item").click() + .elementById("add_payment_button", def_timeout).click().elementByCssSelector("tbody#payment_contents tr td:last-child", def_timeout).text().then(function(value) { assert.equal(value, "$43.56", "price " + value + " in sale register is not correct!!"); - }).elementById("finish_sale_button", 3000).submit().elementByCssSelector("#receipt_items tbody tr:nth-child(7) td:last-child", 5000).text().then(function(value) { + }).elementById("finish_sale_button", def_timeout).submit().elementByCssSelector("#receipt_items tbody tr:nth-child(7) td:last-child", def_timeout).text().then(function(value) { assert.equal(value, "$43.56", "price " + value + " on sale receipt is not correct!!"); - }).elementByCssSelector("#receipt_items tbody tr:nth-child(9) td:last-child div.total-value", 5000).text().then(function(value) { + }).elementByCssSelector("#receipt_items tbody tr:nth-child(9) td:last-child div.total-value", def_timeout).text().then(function(value) { assert.equal(value, "-$43.56", "payment amount " + value + " on sale receipt is not correct!!") }).then(done, done); }); @@ -31,8 +28,8 @@ describe("create item and make sale", function () { it("should be able to make receiving", function(done) { return this.browser.get(ospos.url("/index.php/receivings")) - .elementById("item", 3000).type("1\r\n") - .waitForElementByName("quantity", 3000).clear().type("2").elementByName("edit_item").click() + .elementById("item", def_timeout).type("1\r\n") + .waitForElementByName("quantity", def_timeout).clear().type("2").elementByName("edit_item").click() .elementByCssSelector("td:nth-last-child(2)").text().then(function(value) { assert.equal(value, "$20.00", "price " + value + " in receiving register is not correct!!"); }).elementById("finish_receiving_button").submit().elementByCssSelector("#receipt_items tbody tr:nth-last-child(2) td:nth-child(2) div.total-value").text().then(function(value) { diff --git a/test/ospos.js b/test/ospos.js index 5d9d023ba..b26f5be6f 100644 --- a/test/ospos.js +++ b/test/ospos.js @@ -10,24 +10,38 @@ var ospos = function() { return server + suffix; } , - login : function(browser, done) { - return browser.get(this.url("/index.php")) - .elementByName('username').type("admin").getValue() - .then(function(value) { - assert.equal(value, "admin"); - }) - .elementByName('password').type("pointofsale").getValue() - .then(function(value) { - assert.ok(value, "pointofsale"); - }) - .elementByName('loginButton').click() - .elementById('home_module_list').then(function(value) { - assert.ok(value, "Login failed!!") - }) - .then(done, done); + login : function(browser, done) { + return browser.get(this.url("/index.php")) + .elementByName('username').type("admin").getValue() + .then(function (value) { + assert.equal(value, "admin"); + }) + .elementByName('password').type("pointofsale").getValue() + .then(function (value) { + assert.ok(value, "pointofsale"); + }) + .elementByName('loginButton').click() + .elementById('home_module_list').then(function (value) { + assert.ok(value, "Login failed!!") + }) + .then(done, done); + + }, + + create_item : function(browser, item) + { + return browser.get(this.url("/index.php/items")).elementByCssSelector("a[title='New Item']", 5000).click() + .waitForElementByName("name", 10000).type(item.name).elementById("category").type(item.category) + .elementById('cost_price', 2000).clear().type(item.cost_price).elementById("unit_price", 2000).type(item.unit_price) + .elementById('tax_name_1', 2000).type('VAT').elementById("tax_percent_name_1", 2000).type("21") + .elementById('receiving_quantity', 2000).type(item.receiving_quantity || 1) + .elementById("1_quantity", 2000).type("1").elementById("reorder_level", 2000).type("0").elementById("submit", 2000).click() + .waitForElementByXPath("//table/tbody/tr[td/text()='anItem']/td[3]").text().then(function (value) { + assert.equal(value, "anItem", "item " + item.name + " could not be created!!"); + }); + } - } } }; -module.exports = ospos(); \ No newline at end of file +module.exports = ospos(); diff --git a/test/receiving_quantity.js b/test/receiving_quantity.js new file mode 100644 index 000000000..38a30e38e --- /dev/null +++ b/test/receiving_quantity.js @@ -0,0 +1,31 @@ +var assert = require('assert'); +var ospos = require('./ospos'); + +describe("test receiving quantity", function() { + + var def_timeout = 5000; + + var item = { + name: "recvQty", + category: "aCategory", + cost_price: 10, + unit_price: 20, + receiving_quantity: 2 + }; + + it("should be able to creaate item with receiving quantity", function(done) { + return ospos.create_item(this.browser, item).then(done, done); + }); + + it("should be able to receive quantities with multiplier", function(done) { + this.browser.get(ospos.url('/index.php/receivings')).elementById("item").type(item.name) + .waitForElementByCssSelector(".ac_even", def_timeout).click().waitForElementByName("quantity", def_timeout) + .elementByCssSelector("#cart_contents tr td:nth-child(5)").text().then(function(value) { + assert(value, "x " + item.receiving_quantity, "receiving quantity " + item.receiving_quantity + " is not displayed correctly in receivings module!"); + }).elementById("finish_receiving_button", def_timeout).submit() + .elementByCssSelector("#receipt_items tr:nth-child(2) td:nth-last-child(2)", def_timeout).text().then(function(value) { + assert(value, "1 x " + item.receiving_quantity, "receiving quantity " + item.receiving_quantity + " is not displayed correctly on receipt!!"); + }).then(done, done); + }); + +}); \ No newline at end of file