@buildingsblock/core
Advanced tools
Comparing version 0.0.10 to 0.0.11
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.default = void 0; | ||
exports.default = exports.calcSalesTurnoverRate = exports.calcContingencyReserveFundPerSquareFoot = void 0; | ||
@@ -17,3 +17,2 @@ var _lodash = _interopRequireDefault(require("lodash")); | ||
// import createSchema from './schema' | ||
var calcContingencyReserveFundPerSquareFoot = function calcContingencyReserveFundPerSquareFoot(stratas) { | ||
@@ -34,2 +33,21 @@ var stratasWithContingencyReserveFund = stratas.filter(function (x) { | ||
exports.calcContingencyReserveFundPerSquareFoot = calcContingencyReserveFundPerSquareFoot; | ||
var calcSalesTurnoverRate = function calcSalesTurnoverRate(strata) { | ||
var sales = strata.sales, | ||
units = strata.units; | ||
var _sales$ = sales[0], | ||
pastYear = _sales$.pastYear, | ||
twoYearsAgo = _sales$.twoYearsAgo, | ||
threeYearsAgo = _sales$.threeYearsAgo; | ||
var turnoverRate = { | ||
pastYear: new _decimal.Decimal(pastYear).dividedBy(units).toNumber(), | ||
twoYearsAgo: new _decimal.Decimal(twoYearsAgo).dividedBy(units).toNumber(), | ||
threeYearsAgo: new _decimal.Decimal(threeYearsAgo).dividedBy(units).toNumber() | ||
}; | ||
return turnoverRate; | ||
}; | ||
exports.calcSalesTurnoverRate = calcSalesTurnoverRate; | ||
var createSchema = function createSchema(Mongoose) { | ||
@@ -107,4 +125,5 @@ var StrataSchema = new Mongoose.Schema({ | ||
calcContingencyReserveFundPerSquareFoot: calcContingencyReserveFundPerSquareFoot, | ||
calcSalesTurnoverRate: calcSalesTurnoverRate, | ||
createSchema: createSchema | ||
}; | ||
exports.default = _default; |
{ | ||
"name": "@buildingsblock/core", | ||
"version": "0.0.10", | ||
"version": "0.0.11", | ||
"description": "Core code base for Buildingsblock", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
import test from 'ava' | ||
import { calcContingencyReserveFundPerSquareFoot } from '../../src/stratas' | ||
import { | ||
calcContingencyReserveFundPerSquareFoot, | ||
calcSalesTurnoverRate, | ||
} from '../../src/stratas' | ||
@@ -30,1 +33,14 @@ test('calcContingencyReserveFundPerSquareFoot', (t) => { | ||
}) | ||
test('calcSalesTurnoverRate', (t) => { | ||
const strata = { | ||
sales: [{ pastYear: 10, twoYearsAgo: 5, threeYearsAgo: 20 }], | ||
units: 100, | ||
} | ||
const result = calcSalesTurnoverRate(strata) | ||
t.is(result.pastYear, 0.1, 'should return turnover rate for past year') | ||
t.is(result.twoYearsAgo, 0.05, 'should return turnover rate for two years ago') | ||
t.is(result.threeYearsAgo, 0.2, 'should return turnover rate for three years ago') | ||
}) |
363002
186