Refactor customized amount

This commit is contained in:
Gustavo Maximiliano Cortez 2015-06-26 14:25:53 -03:00
commit 0fc3aa9539
No known key found for this signature in database
GPG key ID: 15EDAD8D9F2EB1AF
2 changed files with 15 additions and 12 deletions

View file

@ -463,12 +463,15 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
$scope.submitForm = function(form) {
var satToBtc = 1 / 100000000;
var amount = form.amount.$modelValue;
var alternative = form.alternative.$modelValue;
if ($scope.unitName == 'bits') {
amount = parseInt((amount * $scope.unitToSatoshi).toFixed(0)) * satToBtc;
}
$scope.customizedAmount = amount;
$scope.customizedAlternative = alternative;
var amountSat = parseInt((amount * $scope.unitToSatoshi).toFixed(0));
$timeout(function() {
$scope.customizedAmountUnit = amount + ' ' + $scope.unitName;
$scope.customizedAlternativeUnit = $filter('noFractionNumber')(form.alternative.$modelValue, 2) + ' ' + $scope.alternativeIsoCode;
if ($scope.unitName == 'bits') {
amount = amountSat * satToBtc;
}
$scope.customizedAmountBtc = amount;
}, 1);
};
$scope.toggleAlternative = function() {