Skip to content

Commit

Permalink
Merge branch 'master' into feature-barcodes
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Niles committed Dec 24, 2016
2 parents 650b4e8 + 5ac6b69 commit 6da516f
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,24 @@ function SearchCashPaymentModalController(Debtors, Users, Cashboxes, Notify, Ins

// client
Debtors.read()
.then(function (list) {
vm.debtors = list;
})
.catch(Notify.handleError);
.then(function (list) {
vm.debtors = list;
})
.catch(Notify.handleError);

// cashboxes
Cashboxes.read()
.then(function (list) {
vm.cashboxes = list;
})
.catch(Notify.handleError);
.then(function (list) {
vm.cashboxes = list;
})
.catch(Notify.handleError);

// users
Users.read()
.then(function (list) {
vm.users = list;
})
.catch(Notify.handleError);
.then(function (list) {
vm.users = list;
})
.catch(Notify.handleError);

function submit() {
var queryParam = formatFilterParameters(vm.bundle);
Expand Down
24 changes: 16 additions & 8 deletions server/controllers/finance/reports/cashflow/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ function processingCashflowReport(params) {
throw new BadRequest('Cashbox is missing', 'ERRORS.BAD_REQUEST');
}

params.dateFrom = moment(params.dateFrom).format('YYYY-MM-DD').toString();
params.dateTo = moment(params.dateTo).format('YYYY-MM-DD').toString();

// get all periods for the the current fiscal year
return getPeriods(params.dateFrom, params.dateTo)
.then(function (periods) {
Expand Down Expand Up @@ -105,14 +108,14 @@ function queryIncomeExpense (params, dateFrom, dateTo) {
pj.account_id, pj.entity_uuid, pj.currency_id, pj.trans_id,
pj.description, pj.comment, pj.origin_id, pj.user_id
FROM posting_journal pj
WHERE pj.account_id IN (?) AND pj.trans_date >= ? AND pj.trans_date <= ?
WHERE pj.account_id IN (?) AND DATE(pj.trans_date) >= DATE(?) AND DATE(pj.trans_date) <= DATE(?)
) UNION (
SELECT gl.project_id, gl.uuid, gl.record_uuid, gl.trans_date,
gl.debit_equiv, gl.credit_equiv, gl.debit, gl.credit,
gl.account_id, gl.entity_uuid, gl.currency_id, gl.trans_id,
gl.description, gl.comment, gl.origin_id, gl.user_id
FROM general_ledger gl
WHERE gl.account_id IN (?) AND gl.trans_date >= ? AND gl.trans_date <= ?
WHERE gl.account_id IN (?) AND DATE(gl.trans_date) >= DATE(?) AND DATE(gl.trans_date) <= DATE(?)
)
) AS t, account AS a, user as u, transaction_type as x
WHERE t.account_id = a.id AND t.user_id = u.id AND t.origin_id = x.id
Expand Down Expand Up @@ -189,6 +192,9 @@ function processingWeekCashflow(params) {
throw new BadRequest('Cashbox is missing', 'ERRORS.BAD_REQUEST');
}

params.dateFrom = moment(params.dateFrom).format('YYYY-MM-DD').toString();
params.dateTo = moment(params.dateTo).format('YYYY-MM-DD').toString();

glb.periods = getWeeks(params.dateFrom, params.dateTo);
glb.balance = { balance: 0, account_id: params.account_id };

Expand Down Expand Up @@ -267,9 +273,9 @@ function closingBalance(accountId, periodStart) {
*/
function getFiscalYear(date) {
var query =
'SELECT fy.id, fy.previous_fiscal_year_id FROM fiscal_year fy ' +
'JOIN period p ON p.fiscal_year_id = fy.id ' +
'WHERE ? BETWEEN p.start_date AND p.end_date';
`SELECT fy.id, fy.previous_fiscal_year_id FROM fiscal_year fy
JOIN period p ON p.fiscal_year_id = fy.id
WHERE ? BETWEEN p.start_date AND p.end_date`;
return db.exec(query, [date]);
}

Expand All @@ -280,9 +286,11 @@ function getFiscalYear(date) {
*/
function getPeriods(dateFrom, dateTo) {
var query =
'SELECT id, number, start_date, end_date ' +
'FROM period WHERE DATE(start_date) >= DATE(?) AND DATE(end_date) <= DATE(?)';
return db.exec(query, [dateFrom, dateTo]);
`SELECT id, number, start_date, end_date
FROM period WHERE (DATE(start_date) >= DATE(?) AND DATE(end_date) <= DATE(?))
OR (DATE(?) BETWEEN DATE(start_date) AND DATE(end_date))
OR (DATE(?) BETWEEN DATE(start_date) AND DATE(end_date));`;
return db.exec(query, [dateFrom, dateTo, dateFrom, dateTo]);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions sh/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ mysql -h $DB_HOST -u root -e "DROP SCHEMA IF EXISTS $DB_NAME;"
mysql -h $DB_HOST -u $DB_USER -p$DB_PASS -e "CREATE SCHEMA $DB_NAME CHARACTER SET utf8 COLLATE utf8_unicode_ci;"
mysql -h $DB_HOST -u $DB_USER -p$DB_PASS $DB_NAME < server/models/schema.sql
mysql -h $DB_HOST -u $DB_USER -p$DB_PASS $DB_NAME < server/models/triggers.sql
mysql -u $DB_USER -u $DB_USER -p$DB_PASS $DB_NAME < server/models/functions.sql
mysql -u $DB_USER -u $DB_USER -p$DB_PASS $DB_NAME < server/models/procedures.sql
mysql -u $DB_USER -u $DB_USER -p$DB_PASS $DB_NAME < server/models/debug.sql
mysql -h $DB_HOST -u $DB_USER -p$DB_PASS $DB_NAME < server/models/functions.sql
mysql -h $DB_HOST -u $DB_USER -p$DB_PASS $DB_NAME < server/models/procedures.sql
mysql -h $DB_HOST -u $DB_USER -p$DB_PASS $DB_NAME < server/models/debug.sql
mysql -h $DB_HOST -u $DB_USER -p$DB_PASS $DB_NAME < server/models/test/data.sql
4 changes: 2 additions & 2 deletions test/end-to-end/cash/cash.registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function CashPaymentsRegistryTests() {

/** Existing reference */
FU.buttons.search();
FU.input('$ctrl.bundle.reference', 'TPA1');
FU.input('$ctrl.bundle.reference', 'CP.TPA.1');
FU.modal.submit();
GU.expectRowCount('payment-registry', 1);

Expand Down Expand Up @@ -111,7 +111,7 @@ function CashPaymentsRegistryTests() {
});

it('successfully Cancel a Cash Payment', () => {
element(by.id(`TPA2`)).click();
element(by.id('CP.TPA.2')).click();
FU.input('ModalCtrl.creditNote.description', 'Cancel This Payment');
FU.modal.submit();
components.notification.hasSuccess();
Expand Down
2 changes: 1 addition & 1 deletion test/end-to-end/patient/invoice/invoice.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function PatientInvoicePage() {
page.prepare = function prepare() {

// set a patient with id TPA1
findPatient.findById('TPA1');
findPatient.findById('PA.TPA.1');

// set the date to the start of this year
dateEditor.set(new Date('2016-01-02'));
Expand Down
2 changes: 1 addition & 1 deletion test/end-to-end/patient/invoice/invoice.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ describe('Patient Invoice', function () {
browser.refresh();

// need to have a patient to recover data
page.patient('TPA1');
page.patient('PA.TPA.1');

// click recover cache button
page.recover();
Expand Down
7 changes: 4 additions & 3 deletions test/end-to-end/patient/invoice/registry.search.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/* jshint expr:true */
/* global element, by, browser */
const chai = require('chai');
Expand All @@ -11,11 +13,10 @@ const FU = require('../../shared/FormUtils');
const InvoiceRegistryPage = require('./registry.page.js');

function InvoiceRegistrySearch() {
'use strict';

const params = {
monthBillNumber : 0,
referenceValue : 'TPA2',
referenceValue : 'IV.TPA.2',
serviceValue : 'Test Service',
userValue : 'Super User',
distributableInvoiceNumber : 4,
Expand Down Expand Up @@ -79,7 +80,7 @@ function InvoiceRegistrySearch() {

it('filters by reference should return a single result', () => {
FU.buttons.search();
FU.input('ModalCtrl.params.reference', 'TPA2');
FU.input('ModalCtrl.params.reference', 'IV.TPA.2');
FU.modal.submit();

expectNumberOfGridRows(1);
Expand Down
2 changes: 1 addition & 1 deletion test/end-to-end/patient/invoice/registry.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('Invoice Registry', () => {

it('Credit Note for reverse any transaction in the posting_journal', () => {

element(by.id('TPA2')).click();
element(by.id('IV.TPA.2')).click();
FU.input('ModalCtrl.creditNote.description', 'Credit Note Error');
FU.modal.submit();
components.notification.hasSuccess();
Expand Down
2 changes: 1 addition & 1 deletion test/end-to-end/patient/record.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('Patient Record', function () {

const patient = {
name : 'Test 2 Patient',
id : 'TPA1',
id : 'PA.TPA.1',
hospital_no : '110',
age : '26',
gender : 'M'
Expand Down
1 change: 0 additions & 1 deletion test/end-to-end/patient/registry.search.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ helpers.configure(chai);

const FU = require('../shared/FormUtils');


/*
* Patient Search Tests
*
Expand Down
4 changes: 3 additions & 1 deletion test/integration/reports/finance/cashflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ describe(`(${target}) Cashflow Reports`, function () {
.catch(helpers.handler);
});

it(`GET ${target}?account_id=3627 should return a BAD_DATE_INTERVAL response`, function () {
// TODO: remove this test
// default date value is the current date if no dates given
it.skip(`GET ${target}?account_id=3627 should return a BAD_DATE_INTERVAL response`, function () {
return agent.get(target)
.query({ account_id : parameters.account_id })
.then(res => {
Expand Down

0 comments on commit 6da516f

Please sign in to comment.