Skip to content

Commit

Permalink
v0.6.0
Browse files Browse the repository at this point in the history
See CHANGELOG.md
  • Loading branch information
GochoMugo committed Nov 14, 2016
2 parents 4f12664 + c813990 commit ecf44d7
Show file tree
Hide file tree
Showing 19 changed files with 263 additions and 143 deletions.
17 changes: 17 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
env:
es6: true
node: true
extends: 'eslint:recommended'
rules:
indent:
- error
- 2
linebreak-style:
- error
- unix
quotes:
- error
- single
semi:
- error
- always
5 changes: 0 additions & 5 deletions .openshift/gitignore

This file was deleted.

6 changes: 1 addition & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
language: node_js
node_js:
- '6'
- '4'
before_deploy:
- mv .openshift/gitignore .gitignore
deploy:
provider: openshift
user: mugo@forfuture.co.ke
password:
secure: UeYKxuX479enwcn1rziErDtnHjR5RFu0a4zK83qZKPhgsXbk+NUXw20fMGtRQvfK/YKm5RW3hqQup6d8dinUJeTqANI4xeunhwV331nWUyzzhRZJUXPb0IiD3idJDpiDDH05leQzSp/8uGt1wb9fYPe1OoN3ylq46RT5kW0tQ/CqkjIOkTPgrX0jY1moANse4RfvGD/6hmgL8nrOM6mqNG2n8fpnoRdznAkZkQlV/vjLEn45SpQEWGmCwn4uFFouXaV3WQMgcuuNvKWQBRS9ZY0VwSNdZoTXvFqaHTxHaPADoMtxszHY18q9XiRpr2TBoBjEXQYtFWBTVN7n3kkQXLHzoMJk/LfsWW3z8lUHVU7Q7MJyuFLj4qRP85neLKQ38CahUCCxbr5IaxvS9/PMysYJi34LYR43SiK2WBf6gdH6SB/GHEJA2IU8TjNmfA0LVbhS/zaDCLD+NRxXghhsaIXAb5JIYfYiOKDwA5WVcIk/Tfz5CpM6M8pYbiP3PYn2bYFr7OY9HL78z0+7NqU4YYiIlgfPf0TKz/FDmtgMJErFNbZbu72uPBryUotjC7zTkSQwtRmyFXGmtc/OpLEnTr3jSK1Sx7BbS1IsravMycNQtzygAykT7SotyhinjE+fXY0fXP59UmQvV/SMjbc6j2GSWsyU4JBF2BV7TpHZMAM=
secure: eVuRZ/p3JerZqPIJxjfITMj4s/mBBfFmyTJNWWotjExdxEPEqxeAJOA5lI6n9d8i6iHUENkpQHJeVzeyMYwd7ove6QkWC1VAK0DHr2siJhrueQIfeX/zNh+aaqxmqYRo+JhneVCEoq/Rr8/NBHTCpg51D1o3WbnCazYzlnnWIAu5rN5LEhLOx3N2EgezkdTbVh82H398P2tyhGHz4qWkzNItVCfRSGsVczSYq3g4qZAQX+pMzG8FWhXZBFiH1SLRAq6Yby2FDkqrsQFJseN/sQx8YSUYscDq+NFjHisSlsvODv2auc8mS40Q1/gvVCK0bmdDBbhpmOBcxUM1xbsyTfYFipE6Ehfw6T+QBjMl1uGW8/s8MvbbcEUe4SDfEugVgIDc8+2zwm2dhWX7kQa2yRwmDzYpWZcVeWphQ95kYkKMiXtjedZWngDSHFjR1OacWtricazXnOmPWQwzXXUQL5Isa+n0KLb8BQDsHHaYSy94cqtGFjSDrCs3X/r6T/jtWtzKul7xth5EMcHn/9DyvCO3F4hAZWb6hwTaQ2ea0J1DM8Cu4J48+Sg2MpgF8Al9HfrcHDKsRicMLuqmxaPkrB2L6qLGc/h6RoLNCIGDl6mn3Af/anQluh6GXnCQum24qk3dmcoJ5Y+NxhikckR2NdNxK5LXnkN3ogpbvwdHZEI=
app: mmtcke
domain: forfutureco
on:
repo: forfuturellc/mmtc-ke
branch: master
skip_cleanup: true
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ This project adheres to [Semantic Versioning](http://semver.org/).



## [0.6.0][0.6.0] - 2016-11-14

Added:

* Add support for **fractional parts** in the `amount`.

Changed:

* Drop official support for Node v4.x series


## [0.5.0][0.5.0] - 2016-11-11

Added:
Expand Down Expand Up @@ -74,10 +85,11 @@ Added:
This is the very first version.


[Unreleased]: https://github.com/forfuturellc/mmtc-ke/compare/v0.5.0...HEAD
[0.0.0]:https://github.com/forfuturellc/mmtc-ke/releases/tag/v0.0.0
[0.1.0]:https://github.com/forfuturellc/mmtc-ke/releases/tag/v0.1.0
[0.2.0]:https://github.com/forfuturellc/mmtc-ke/releases/tag/v0.2.0
[0.3.0]:https://github.com/forfuturellc/mmtc-ke/releases/tag/v0.3.0
[0.4.0]:https://github.com/forfuturellc/mmtc-ke/releases/tag/v0.4.0
[0.5.0]:https://github.com/forfuturellc/mmtc-ke/releases/tag/v0.5.0
[0.6.0]:https://github.com/forfuturellc/mmtc-ke/releases/tag/v0.6.0
[Unreleased]: https://github.com/forfuturellc/mmtc-ke/compare/v0.6.0...HEAD
14 changes: 13 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ exports = module.exports = (grunt) => {
loadGruntTasks(grunt);

grunt.initConfig({
eslint: {
src: [
'app.js',
'config/**/*.js',
'engine/**/*.js',
'Gruntfile.js',
'routes/**/*.js',
'web/js/*.js',
],
},
sass: {
dist: {
files: [{
Expand All @@ -18,5 +28,7 @@ exports = module.exports = (grunt) => {
},
});

grunt.registerTask("build", ["sass"]);
grunt.registerTask('build', ['sass']);
grunt.registerTask('lint', ['eslint']);
grunt.registerTask('test', ['lint']);
};
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
>
> Running at **http://mmtc.forfuture.co.ke**
[![Supported Node.js Versions](https://img.shields.io/badge/node->=6-green.svg)](https://github.com/forfuturellc/mmtc-ke)
[![Build Status](https://travis-ci.org/forfuturellc/mmtc-ke.svg?branch=master)](https://travis-ci.org/forfuturellc/mmtc-ke)
<!--[![Coverage Status](https://coveralls.io/repos/github/forfuturellc/mmtc-ke/badge.svg?branch=master)](https://coveralls.io/github/forfuturellc/mmtc-ke?branch=master)-->
[![Dependency Status](https://gemnasium.com/forfuturellc/mmtc-ke.svg)](https://gemnasium.com/forfuturellc/mmtc-ke)


## hacking:

Expand Down
42 changes: 21 additions & 21 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const app = express();
const debug = Debug('mmtc-ke:app');
const logger = engine.clients.getLogger();
let nunjucksEnv;
const devmode = app.get("env") === "development";
const devmode = app.get('env') === 'development';


debug('initializing engine');
Expand All @@ -40,16 +40,16 @@ engine.init();

debug('configuring nunjucks');
nunjucksEnv = nunjucks.configure('web', {
autoescape: true,
express: app,
noCache: devmode ? true : false,
autoescape: true,
express: app,
noCache: devmode ? true : false,
});


debug("adding global variables for nunjucks templates");
nunjucksEnv.addGlobal("pkg", pkg);
nunjucksEnv.addGlobal("site", config.get("site"));
nunjucksEnv.addGlobal("env", process.env);
debug('adding global variables for nunjucks templates');
nunjucksEnv.addGlobal('pkg', pkg);
nunjucksEnv.addGlobal('site', config.get('site'));
nunjucksEnv.addGlobal('env', process.env);


debug('setting up views');
Expand All @@ -61,12 +61,12 @@ app.set('view engine', 'html');


debug('disabling Express view cache');
app.set("view cache", false);
app.set('view cache', false);


debug('mounting middleware for parsing request body');
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.urlencoded({ extended: false }));


debug('mounting middleware for serving static files');
Expand All @@ -78,24 +78,24 @@ app.use(routes);


debug('mounting catch-all handler');
app.use(function(req, res, next) {
return routes.utils.renderPage(req, res, 'error', {
error: new engine.errors.PageNotFoundError(`page '${req.path}' not found`),
});
app.use(function(req, res) {
return routes.utils.renderPage(req, res, 'error', {
error: new engine.errors.PageNotFoundError(`page '${req.path}' not found`),
});
});


debug('mounting middleware for error handling');
app.use(function(err, req, res, next) {
logger.error(err);
return routes.utils.renderPage(req, res, 'error', {
error: err,
});
app.use(function(err, req, res, next) { // eslint-disable-line no-unused-vars
logger.error(err);
return routes.utils.renderPage(req, res, 'error', {
error: err,
});
});


debug('starting server');
app.listen(config.get('server.port'), config.get('server.ip'), function() {
logger.info('server listening');
debug('server started at http://%s:%s', config.get('server.ip'), config.get('server.port'));
logger.info('server listening');
debug('server started at http://%s:%s', config.get('server.ip'), config.get('server.port'));
});
12 changes: 6 additions & 6 deletions config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ config.server.ip = process.env.OPENSHIFT_NODEJS_IP || '127.0.0.1';

// site configuration
config.site = {};
config.site.title = `Mobile Money Transaction Cost in Kenya`;
config.site.title_short = `mmtc | ke`;
config.site.email = `we@forfuture.co.ke`;
config.site.description = `An easy way to calculate cost of mobile money transcations in Kenya`
config.site.url = `mmtc.forfuture.co.ke`;
config.site.baseurl = ``;
config.site.title = 'Mobile Money Transaction Cost in Kenya';
config.site.title_short = 'mmtc | ke';
config.site.email = 'we@forfuture.co.ke';
config.site.description = 'An easy way to calculate cost of mobile money transcations in Kenya';
config.site.url = 'mmtc.forfuture.co.ke';
config.site.baseurl = '';
config.site.author = {};
config.site.author.name = 'Forfuture LLC';
config.site.author.url = 'http://forfuture.co.ke';
Expand Down
3 changes: 1 addition & 2 deletions data/SPEC.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

|Aspect|Detail|
|------|------|
|Version|0.4|
|Version|0.5|
|Written by|GochoMugo <mugo@forfuture.co.ke>|

The data used in the application in its computations is fed through data files
Expand Down Expand Up @@ -81,7 +81,6 @@ additions:
* `-2`: raises `AmountNotFoundError`, inferring that the amount for
this transaction can **not** be determined using our data (depends on
external factors, e.g. merchant reputation)
* **no** fractional part

Therefore, the cost is accurate to **1 KES**.

Expand Down
2 changes: 1 addition & 1 deletion data/airtel-money.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "airtel money",
"name": "airtel-money",
"meta": {
"spec": "0.2",
"date_updated": "2016-06-16",
Expand Down
67 changes: 67 additions & 0 deletions data/equitel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"name": "equitel",
"meta": {
"spec": "0.5",
"date_updated": "2016-11-11",
"url": "http://www.equitel.com/my-money/rates"
},
"transactions": [
{
"name": "transfer",
"classes": [
{
"name": "equitel or orange money",
"ranges": [
{ "low": "-Infinity", "high": 49, "amount": -1 },
{ "low": 50, "high": 35000, "amount": 0 },
{ "low": 35001, "high": "+Infinity", "amount": -1 }
]
},
{
"name": "mpesa or airtel money",
"ranges": [
{ "low": "-Infinity", "high": 49, "amount": -1 },
{ "low": 50, "high": 100, "amount": 34.1 },
{ "low": 101, "high": 500, "amount": 38.5 },
{ "low": 501, "high": 1000, "amount": 44 },
{ "low": 1001, "high": 1500, "amount": 49.5 },
{ "low": 1501, "high": 35000, "amount": 60.5 },
{ "low": 35001, "high": "+Infinity", "amount": -1 }
]
}
]
},
{
"name": "others",
"amount_input": false,
"classes": [
{
"name": "deposits",
"amount": 0
},
{
"name": "transaction reports",
"amount": 0
},
{
"name": "airtime",
"amount": 0
},
{
"name": "balance enquiry",
"amount": 0
},
{
"name": "pay bills",
"amount": 0
},
{
"name": "atm withdrawal",
"amount": 33
}
]
}
],
"ussd_codes": [
]
}
2 changes: 1 addition & 1 deletion data/mpesa.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mpesa",
"meta": {
"spec": "0.2",
"spec": "0.4",
"date_updated": "2016-11-11",
"url": "http://www.safaricom.co.ke/personal/m-pesa"
},
Expand Down
12 changes: 8 additions & 4 deletions engine/math.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ exports = module.exports = {
* transaction was not found
* @throws RangeNotFoundError if the amount was not found in any range
* @throws InvalidAmountError if the amount entered was invalid
* @throws AmountNotAllowedError if the amount is not allowed for the
* transaction
* @throws AmountNotFoundError if the amount can not be determined using
* the data available to the engine
*/
calculate: calculate,
/**
Expand Down Expand Up @@ -75,7 +79,7 @@ function calculate(name, params) {

let amount, range;

amount = parseInt(params.amount, 10);
amount = Number(params.amount);
if (amount < 0) {
throw new errors.InvalidAmountError(`amount '${params.amount}' is not valid`);
}
Expand All @@ -90,9 +94,9 @@ function calculate(name, params) {

switch (range.amount) {
case -1:
throw new errors.AmountNotAllowedError(`amount is not allowed`);
throw new errors.AmountNotAllowedError('amount is not allowed');
case -2:
throw new errors.AmountNotFoundError(range.message || `amount not found`);
throw new errors.AmountNotFoundError(range.message || 'amount not found');
}

return range.amount;
Expand All @@ -118,6 +122,6 @@ function parseRange(range) {
} else if (n === '+Infinity') {
return +Infinity;
}
return parseInt(n, 10);
return Number(n);
}
}
Loading

0 comments on commit ecf44d7

Please sign in to comment.