diff --git a/src/currencyservice/server.js b/src/currencyservice/server.js index a1429d8..7cd6539 100644 --- a/src/currencyservice/server.js +++ b/src/currencyservice/server.js @@ -95,19 +95,24 @@ function convert (call, callback) { nanos: from.nanos / data[from.currency_code] }); + euros.nanos = Math.round(euros.nanos); + // Convert: EUR --> to_currency const result = _carry({ units: euros.units * data[request.to_code], nanos: euros.nanos * data[request.to_code] }); - result.nanos = Math.round(result.nanos); + + result.units = Math.floor(result.units) + result.nanos = Math.floor(result.nanos) result.currency_code = request.to_code; - console.log('Conversion request successful.'); + console.log(`Conversion request successful ${result.nanos}..${result.nanos}`); callback(null, result); }); } catch (err) { console.error('Conversion request failed.'); + console.error(err); callback(err.message); } }