Bug fix
- Fixed: incorrect eCode file mapped - moved productStr inside IIF - Fixed: some minor syntax bugs
This commit is contained in:
parent
7c99f41e48
commit
80879a250b
@ -513,6 +513,7 @@
|
|||||||
INSUFFICIENT_BALANCE: '201',
|
INSUFFICIENT_BALANCE: '201',
|
||||||
INSUFFICIENT_SELLCHIP: '203',
|
INSUFFICIENT_SELLCHIP: '203',
|
||||||
GREATER_SELLCHIP_BASE: '204',
|
GREATER_SELLCHIP_BASE: '204',
|
||||||
|
INSUFFICIENT_PERIOD: '206',
|
||||||
|
|
||||||
//OTHERS
|
//OTHERS
|
||||||
NODES_OFFLINE: '404',
|
NODES_OFFLINE: '404',
|
||||||
|
|||||||
@ -1,11 +1,13 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const eCode = require('../eCode_test')// require('../../docs/scripts/floExchangeAPI').errorCode;
|
const eCode = require('../../docs/scripts/floExchangeAPI').errorCode;
|
||||||
const getRate = require('./conversion').getRate;
|
const getRate = require('./conversion').getRate;
|
||||||
|
|
||||||
var DB; //container for database
|
var DB; //container for database
|
||||||
|
|
||||||
const blockchainBond = (function () {
|
const blockchainBond = (function () {
|
||||||
|
const productStr = "Product: RanchiMall Bitcoin Bond";
|
||||||
|
|
||||||
const magnitude = m => {
|
const magnitude = m => {
|
||||||
switch (m) {
|
switch (m) {
|
||||||
case "thousand": return 1000;
|
case "thousand": return 1000;
|
||||||
@ -83,7 +85,7 @@ const blockchainBond = (function () {
|
|||||||
|
|
||||||
function stringify_main(BTC_base, start_date, guaranteed_interest, guarantee_period, gain_cut, amount, USD_base, lockin_period, floID) {
|
function stringify_main(BTC_base, start_date, guaranteed_interest, guarantee_period, gain_cut, amount, USD_base, lockin_period, floID) {
|
||||||
return [
|
return [
|
||||||
`Product: RanchiMall Bitcoin Bond`,
|
`${productStr}`,
|
||||||
`Base value: ${BTC_base} USD`,
|
`Base value: ${BTC_base} USD`,
|
||||||
`Date of bond start: ${start_date}`,
|
`Date of bond start: ${start_date}`,
|
||||||
`Guaranteed interest: ${guaranteed_interest}% per annum simple for ${guarantee_period}`,
|
`Guaranteed interest: ${guaranteed_interest}% per annum simple for ${guarantee_period}`,
|
||||||
@ -123,10 +125,9 @@ const blockchainBond = (function () {
|
|||||||
return details;
|
return details;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function stringify_end(bond_id, end_date, BTC_net, USD_net, amount, ref_sign, payment_ref) {
|
function stringify_end(bond_id, end_date, BTC_net, USD_net, amount, ref_sign, payment_ref) {
|
||||||
return [
|
return [
|
||||||
`Product: RanchiMall Bitcoin Bond`,
|
`${productStr}`,
|
||||||
`Bond: ${bond_id}`,
|
`Bond: ${bond_id}`,
|
||||||
`End value: ${BTC_net} USD`,
|
`End value: ${BTC_net} USD`,
|
||||||
`Date of bond end: ${end_date}`,
|
`Date of bond end: ${end_date}`,
|
||||||
@ -143,7 +144,7 @@ const blockchainBond = (function () {
|
|||||||
d = d.split(': ');
|
d = d.split(': ');
|
||||||
switch (d[0].toLowerCase()) {
|
switch (d[0].toLowerCase()) {
|
||||||
case "bond":
|
case "bond":
|
||||||
details["bondID"] = d[1];
|
details["bondID"] = d[1]; break;
|
||||||
case "end value":
|
case "end value":
|
||||||
details["BTC_net"] = parseNumber(d[1].slice(0, -4)); break;
|
details["BTC_net"] = parseNumber(d[1].slice(0, -4)); break;
|
||||||
case "date of bond end":
|
case "date of bond end":
|
||||||
@ -160,6 +161,7 @@ const blockchainBond = (function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
productStr,
|
||||||
dateAdder,
|
dateAdder,
|
||||||
dateFormat,
|
dateFormat,
|
||||||
calcNetValue,
|
calcNetValue,
|
||||||
@ -177,8 +179,7 @@ const blockchainBond = (function () {
|
|||||||
|
|
||||||
blockchainBond.config = {
|
blockchainBond.config = {
|
||||||
adminID: "FBBstZ2GretgQqDP55yt8iVd4KNZkdvEzH",
|
adminID: "FBBstZ2GretgQqDP55yt8iVd4KNZkdvEzH",
|
||||||
application: "BlockchainBonds",
|
application: "BlockchainBonds"
|
||||||
productStr: "Product: RanchiMall Bitcoin Bond",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function refreshBlockchainData(nodeList = []) {
|
function refreshBlockchainData(nodeList = []) {
|
||||||
@ -189,7 +190,7 @@ function refreshBlockchainData(nodeList = []) {
|
|||||||
ignoreOld: lastTx,
|
ignoreOld: lastTx,
|
||||||
senders: [nodeList].concat(blockchainBond.config.adminID), //sentOnly: true,
|
senders: [nodeList].concat(blockchainBond.config.adminID), //sentOnly: true,
|
||||||
tx: true,
|
tx: true,
|
||||||
filter: d => d.startsWith(blockchainBond.config.productStr)
|
filter: d => d.startsWith(blockchainBond.productStr)
|
||||||
}).then(result => {
|
}).then(result => {
|
||||||
let promises = [];
|
let promises = [];
|
||||||
result.data.forEach(d => {
|
result.data.forEach(d => {
|
||||||
@ -201,7 +202,6 @@ function refreshBlockchainData(nodeList = []) {
|
|||||||
let details = blockchainBond.parse.end(d.data);
|
let details = blockchainBond.parse.end(d.data);
|
||||||
if (details.bondID && details.amountFinal)
|
if (details.bondID && details.amountFinal)
|
||||||
promises.push(DB.query("UPDATE BlockchainBonds SET close_id=? amount_out=? WHERE bond_id=?", [d.txid, details.amountFinal, details.bondID]));
|
promises.push(DB.query("UPDATE BlockchainBonds SET close_id=? amount_out=? WHERE bond_id=?", [d.txid, details.amountFinal, details.bondID]));
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
promises.push(DB.query("INSERT INTO LastTx (floID, num) VALUE (?, ?) ON DUPLICATE KEY UPDATE num=?", [blockchainBond.config.adminID, result.totalTxs, result.totalTxs]));
|
promises.push(DB.query("INSERT INTO LastTx (floID, num) VALUE (?, ?) ON DUPLICATE KEY UPDATE num=?", [blockchainBond.config.adminID, result.totalTxs, result.totalTxs]));
|
||||||
@ -235,7 +235,7 @@ function closeBond(bond_id, floID, ref) {
|
|||||||
getRate.USD_INR().then(usd_rate => {
|
getRate.USD_INR().then(usd_rate => {
|
||||||
let end_date = new Date(),
|
let end_date = new Date(),
|
||||||
net_value = blockchainBond.calcNetValue(bond.btc_base, btc_rate, bond.begin_date, bond.min_ipa, bond.max_period, bond.gain_cut, bond.amount_in, bond.usd_base, usd_rate);
|
net_value = blockchainBond.calcNetValue(bond.btc_base, btc_rate, bond.begin_date, bond.min_ipa, bond.max_period, bond.gain_cut, bond.amount_in, bond.usd_base, usd_rate);
|
||||||
DB.query("INSERT INTO CloseBondTransact(bond_id, amount, end_date, btc_net, usd_net, ref_sign, status) VALUE ?", [[bond_id, net_value, end_date, btc_rate, usd_rate, ref, "PENDING"]])
|
DB.query("INSERT INTO CloseBondTransact(bond_id, floID, amount, end_date, btc_net, usd_net, ref_sign, status) VALUE ?", [[bond_id, floID, net_value, end_date, btc_rate, usd_rate, ref, "PENDING"]])
|
||||||
.then(result => resolve({ "USD_net": usd_rate, "BTC_net": btc_rate, "amount_out": net_value, "end_date": end_date }))
|
.then(result => resolve({ "USD_net": usd_rate, "BTC_net": btc_rate, "amount_out": net_value, "end_date": end_date }))
|
||||||
.catch(error => reject(error))
|
.catch(error => reject(error))
|
||||||
}).catch(error => reject(error))
|
}).catch(error => reject(error))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user