Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: run eslint --fix on server files #4132

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/src/js/components/bhFonctionSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ FonctionSelectController.$inject = [
*/
function FonctionSelectController(functions, Notify) {
const $ctrl = this;
$ctrl.label = $ctrl.label || 'FORM.LABELS.PROFESSION';
$ctrl.$onInit = function onInit() {
$ctrl.label = $ctrl.label || 'FORM.LABELS.PROFESSION';

functions.read()
.then(fct => {
Expand Down
52 changes: 26 additions & 26 deletions client/src/modules/functions/functions.routes.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
angular.module('bhima.routes')
.config(['$stateProvider', function ($stateProvider) {
$stateProvider
.state('functions', {
url : '/functions',
controller : 'FunctionManagementController as FunctionCtrl',
templateUrl : 'modules/functions/functions.html',
})
.config(['$stateProvider', ($stateProvider) => {
$stateProvider
.state('functions', {
url : '/functions',
controller : 'FunctionManagementController as FunctionCtrl',
templateUrl : 'modules/functions/functions.html',
})

.state('functions.create', {
url : '/create',
params : {
function : { value : null },
creating : { value : true },
},
onEnter : ['$uibModal', functionModal],
onExit : ['$uibModalStack', closeModal],
})
.state('functions.create', {
url : '/create',
params : {
function : { value : null },
creating : { value : true },
},
onEnter : ['$uibModal', functionModal],
onExit : ['$uibModalStack', closeModal],
})

.state('functions.edit', {
url : '/:id/edit',
params : {
function : { value : null },
creating : { value : false },
},
onEnter : ['$uibModal', functionModal],
onExit : ['$uibModalStack', closeModal],
});
}]);
.state('functions.edit', {
url : '/:id/edit',
params : {
function : { value : null },
creating : { value : false },
},
onEnter : ['$uibModal', functionModal],
onExit : ['$uibModalStack', closeModal],
});
}]);

function functionModal($modal) {
$modal.open({
Expand Down
6 changes: 3 additions & 3 deletions client/src/modules/functions/functions.service.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
angular.module('bhima.services')
.service('FunctionService', FunctionService);

FunctionService.$inject = ['PrototypeApiService', '$uibModal'];
FunctionService.$inject = ['PrototypeApiService'];

/**
* @class FunctionService
Expand All @@ -10,8 +10,8 @@ FunctionService.$inject = ['PrototypeApiService', '$uibModal'];
* @description
* Encapsulates common requests to the /functions/ URL.
*/
function FunctionService(Api, Modal) {
var service = new Api('/functions/');
function FunctionService(Api) {
const service = new Api('/functions/');

return service;
}
2 changes: 1 addition & 1 deletion server/controllers/admin/users/cashboxes.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function create(req, res, next) {
if (!cashboxPermissionIds) {
next(new BadRequest(
'You must provide a list of cashbox ids to update the users permissions',
'ERRORS.BAD_DATA_FORMAT'
'ERRORS.BAD_DATA_FORMAT',
));
return;
}
Expand Down
1 change: 0 additions & 1 deletion server/controllers/admin/users/projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,3 @@ function list(req, res, next) {
.catch(next)
.done();
}

3 changes: 1 addition & 2 deletions server/controllers/finance/accounts/categories.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,7 @@ function remove(req, res, next) {
* @returns {Promise} - a promise resolving to the result of the database.
*/
function lookupAccountCategory(id) {
const sql =
'SELECT ac.id, ac.category FROM account_category AS ac WHERE ac.id = ?;';
const sql = 'SELECT ac.id, ac.category FROM account_category AS ac WHERE ac.id = ?;';

return db.one(sql, id);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function compute(periodId) {
const dbPromises = accountReferences.map(ar => {
return references.getAccountsForReference(
ar.abbr,
ar.is_amo_dep
ar.is_amo_dep,
);
});
return Q.all(dbPromises);
Expand Down
2 changes: 1 addition & 1 deletion server/controllers/finance/accounts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ function getOpeningBalanceForPeriod(req, res, next) {
debug(
'#getOpeningBalanceForPeriod() finding opening balance for account %s on period %s',
accountId,
req.query.period
req.query.period,
);

let promise = q();
Expand Down
6 changes: 2 additions & 4 deletions server/controllers/finance/accounts/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ function detail(req, res, next) {
* GET /accounts/types
*/
function list(req, res, next) {
const sql =
'SELECT `id`, `type`, `translation_key` FROM account_type;';
const sql = 'SELECT `id`, `type`, `translation_key` FROM account_type;';

db.exec(sql)
.then((rows) => {
Expand Down Expand Up @@ -142,8 +141,7 @@ function remove(req, res, next) {
* @returns {Promise} - a promise resolving to the result of the database.
*/
function lookupAccountType(id) {
const sql =
'SELECT at.id, at.type FROM account_type AS at WHERE at.id = ?;';
const sql = 'SELECT at.id, at.type FROM account_type AS at WHERE at.id = ?;';

return db.one(sql, id);
}
Expand Down
15 changes: 5 additions & 10 deletions server/controllers/finance/cashboxes/currencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ exports.update = update;
* GET /cashboxes/:id/currencies
*/
function list(req, res, next) {
const sql =
`SELECT id, currency_id, account_id, transfer_account_id
const sql = `SELECT id, currency_id, account_id, transfer_account_id
FROM cash_box_account_currency WHERE cash_box_id = ?;`;

db.exec(sql, [req.params.id])
Expand All @@ -48,8 +47,7 @@ function list(req, res, next) {
* GET /cashboxes/:id/currencies/:currencyId
*/
function detail(req, res, next) {
const sql =
`SELECT id, account_id, transfer_account_id
const sql = `SELECT id, account_id, transfer_account_id
FROM cash_box_account_currency
WHERE cash_box_id = ? AND currency_id = ?;`;

Expand Down Expand Up @@ -78,8 +76,7 @@ function create(req, res, next) {
const data = req.body;
data.cash_box_id = req.params.id;

const sql =
'INSERT INTO cash_box_account_currency SET ?;';
const sql = 'INSERT INTO cash_box_account_currency SET ?;';

db.exec(sql, [data])
.then((row) => {
Expand All @@ -101,15 +98,13 @@ function create(req, res, next) {
function update(req, res, next) {
const data = req.body;

let sql =
`UPDATE cash_box_account_currency SET ?
let sql = `UPDATE cash_box_account_currency SET ?
WHERE cash_box_id = ? AND currency_id = ?;`;

db.exec(sql, [data, req.params.id, req.params.currencyId])
.then(() => {
// send the changed object to the client
sql =
`SELECT id, account_id, transfer_account_id
sql = `SELECT id, account_id, transfer_account_id
FROM cash_box_account_currency
WHERE cash_box_id = ? AND currency_id = ?;`;

Expand Down
2 changes: 1 addition & 1 deletion server/controllers/finance/cashboxes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function list(req, res, next) {
'user_id',
`cash_box.id IN (
SELECT cashbox_permission.cashbox_id FROM cashbox_permission WHERE cashbox_permission.user_id = ?
)`
)`,
);

filters.setOrder('ORDER BY label');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const referenceAccount = require('./referenceAccount');
const generalLedger = require('../generalLedger');

function configuration(req, res, next) {
const query = req.query;
const { query } = req;
let refAccounts;

const params = {
Expand Down
4 changes: 2 additions & 2 deletions server/controllers/finance/generalLedger/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ function getAccountTotalsMatrix(fiscalYearId) {
// correct period.
const columns = PERIODS.reduce(
(q, number) => `${q}, SUM(IF(p.number = ${number}, pt.debit - pt.credit, 0)) AS balance${number}`,
''
'',
);

const outerColumns = PERIODS
Expand Down Expand Up @@ -182,7 +182,7 @@ function getAccountTotalsMatrix(fiscalYearId) {
function getAccountTotalsMatrixAggregates(fiscalYearId) {
const columns = PERIODS.reduce(
(q, number) => `${q}, SUM(IF(p.number = ${number}, pt.debit - pt.credit, 0)) AS balance${number}`,
''
'',
);

const outerColumns = PERIODS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ function processInvoiceItems(invoiceUuid, invoiceItems) {
// create a filter to align invoice item columns to the SQL columns
const filter = util.take(
'uuid', 'inventory_uuid', 'quantity', 'transaction_price',
'inventory_price', 'debit', 'credit', 'invoice_uuid'
'inventory_price', 'debit', 'credit', 'invoice_uuid',
);

// prepare invoice items for insertion into database
Expand Down
22 changes: 11 additions & 11 deletions server/controllers/finance/journal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ function naiveTransactionSearch(options, includeNonPosted) {

return db.exec(
`(${posted.sql}) UNION ALL (${nonPosted.sql}) ORDER BY trans_date DESC ${limitCondition}`,
combinedParameters
combinedParameters,
);
}

Expand Down Expand Up @@ -171,7 +171,7 @@ function buildTransactionQuery(options, posted) {
const { amount } = options;
filters.custom(
'amount', '(credit = ? OR debit = ? OR credit_equiv = ? OR debit_equiv = ?)',
[amount, amount, amount, amount]
[amount, amount, amount, amount],
);

filters.custom('excludes_distributed', 'p.uuid NOT IN (SELECT fc.row_uuid FROM fee_center_distribution AS fc)');
Expand Down Expand Up @@ -297,7 +297,7 @@ function editTransaction(req, res, next) {
if (posted) {
throw new BadRequest(
`Posted transactions cannot be edited. Transaction ${transactionId} is already posted.`,
'POSTING_JOURNAL.ERRORS.TRANSACTION_ALREADY_POSTED'
'POSTING_JOURNAL.ERRORS.TRANSACTION_ALREADY_POSTED',
);
}

Expand All @@ -308,7 +308,7 @@ function editTransaction(req, res, next) {
if (allRowsRemoved || singleRow) {
throw new BadRequest(
`Transaction ${transactionId} has too few rows! A valid transaction must contain at least two rows.`,
'POSTING_JOURNAL.ERRORS.TRANSACTION_MUST_CONTAIN_ROWS'
'POSTING_JOURNAL.ERRORS.TRANSACTION_MUST_CONTAIN_ROWS',
);
}

Expand All @@ -322,7 +322,7 @@ function editTransaction(req, res, next) {
if (fiscalYear.locked) {
throw new BadRequest(
`${fiscalYear.label} is closed and locked. You cannot make transactions against it.`,
'POSTING_JOURNAL.ERRORS.CLOSED_FISCAL_YEAR'
'POSTING_JOURNAL.ERRORS.CLOSED_FISCAL_YEAR',
);
}

Expand Down Expand Up @@ -486,7 +486,7 @@ function transformColumns(rows, newRecord, transactionToEdit, setFiscalData) {
if (!amount && isDebitEquivNonZero) {
throw new BadRequest(
'Missing or corrupt exchange rate for rows',
'POSTING_JOURNAL.ERRORS.MISSING_EXCHANGE_RATE'
'POSTING_JOURNAL.ERRORS.MISSING_EXCHANGE_RATE',
);
}

Expand All @@ -508,7 +508,7 @@ function transformColumns(rows, newRecord, transactionToEdit, setFiscalData) {
if (!amount && isDebitNonZero) {
throw new BadRequest(
'Missing or corrupt exchange rate for rows',
'POSTING_JOURNAL.ERRORS.MISSING_EXCHANGE_RATE'
'POSTING_JOURNAL.ERRORS.MISSING_EXCHANGE_RATE',
);
}

Expand All @@ -530,7 +530,7 @@ function transformColumns(rows, newRecord, transactionToEdit, setFiscalData) {
if (!amount && isCreditEquivNonZero) {
throw new BadRequest(
'Missing or corrupt exchange rate for rows',
'POSTING_JOURNAL.ERRORS.MISSING_EXCHANGE_RATE'
'POSTING_JOURNAL.ERRORS.MISSING_EXCHANGE_RATE',
);
}

Expand All @@ -552,7 +552,7 @@ function transformColumns(rows, newRecord, transactionToEdit, setFiscalData) {
if (!amount && isCreditNonZero) {
throw new BadRequest(
'Missing or corrupt exchange rate for rows',
'POSTING_JOURNAL.ERRORS.MISSING_EXCHANGE_RATE'
'POSTING_JOURNAL.ERRORS.MISSING_EXCHANGE_RATE',
);
}

Expand All @@ -573,7 +573,7 @@ function transformColumns(rows, newRecord, transactionToEdit, setFiscalData) {

promises = databaseRequests.map(
(request, index) => db.exec(request, databaseValues[index])
.then(results => assignments[index](results))
.then(results => assignments[index](results)),
);

return q.all(promises)
Expand Down Expand Up @@ -628,7 +628,7 @@ async function reverseTransaction(recordUuid, userId, reverseDescription) {
// transaction already cancelled
throw new BadRequest(
'The transaction has been already cancelled',
'POSTING_JOURNAL.ERRORS.MULTIPLE_CANCELLING'
'POSTING_JOURNAL.ERRORS.MULTIPLE_CANCELLING',
);
}

Expand Down
3 changes: 1 addition & 2 deletions server/controllers/finance/ledgers/general.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ const db = require('../../../lib/db');
/** queries the general ledger for all columns */
// route: /ledgers/general?since={date}
exports.route = function list(req, res, next) {
const sql =
`SELECT gl.uuid, gl.fiscal_year_id, gl.period_id, gl.trans_id, gl.trans_date, gl.doc_num, gl.description,
const sql = `SELECT gl.uuid, gl.fiscal_year_id, gl.period_id, gl.trans_id, gl.trans_date, gl.doc_num, gl.description,
gl.account_id, gl.debit, gl.credit, gl.debit_equiv, gl.credit_equiv, gl.currency_id, gl.deb_cred_uuid,
gl.deb_cred_type, gl.inv_po_id, gl.comment, gl.cost_ctrl_id, gl.transaction_type_id, gl.user_id, acc.number
FROM general_ledger AS gl JOIN account AS acc
Expand Down
2 changes: 1 addition & 1 deletion server/controllers/finance/trialBalance/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function validateTransactions(transactions) {
if (hasInvalidTransactions) {
throw new BadRequest(
'No transactions were submitted. Please ensure that some are selected.',
'POSTING_JOURNAL.ERRORS.MISSING_TRANSACTIONS'
'POSTING_JOURNAL.ERRORS.MISSING_TRANSACTIONS',
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion server/controllers/finance/voucherTools/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ async function correctTransaction(transactionDetails, correction, userId) {
const reversalResult = await journal.reverseTransaction(
db.bid(transactionUuid),
userId,
transactionDetails.description
transactionDetails.description,
);

// reversal has been correctly executed; this returns the voucherUuid for this document
Expand Down
2 changes: 1 addition & 1 deletion server/controllers/inventory/depots/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ function list(req, res, next) {

filters.custom(
'user_id',
'd.uuid IN (SELECT depot_permission.depot_uuid FROM depot_permission WHERE depot_permission.user_id = ?)'
'd.uuid IN (SELECT depot_permission.depot_uuid FROM depot_permission WHERE depot_permission.user_id = ?)',
);
filters.fullText('text', 'text', 'd');
filters.equals('is_warehouse', 'is_warehouse', 'd');
Expand Down
2 changes: 1 addition & 1 deletion server/controllers/medical/patients/groups.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function update(req, res, next) {
if (!req.body.assignments) {
next(new BadRequest(
`Request must specify an "assignments" object containing an array of patient group ids.`,
'ERROR.ERR_MISSING_INFO'
'ERROR.ERR_MISSING_INFO',
));

return;
Expand Down
Loading