First attempt at #142. Needs a lot of work still.

This commit is contained in:
James Cole
2016-04-29 20:59:28 +02:00
parent 4af8272faa
commit 0e3ccebd0b
19 changed files with 714 additions and 155 deletions

View File

@@ -32,23 +32,6 @@ var colourSet = [
];
// Settings object that controls default parameters for library methods:
accounting.settings = {
currency: {
symbol: currencySymbol, // default currency symbol is '$'
format: "%s %v", // controls output: %s = symbol, %v = value/number (can be object: see below)
decimal: mon_decimal_point, // decimal point separator
thousand: mon_thousands_sep, // thousands separator
precision: frac_digits // decimal places
},
number: {
precision: 0, // default precision on numbers is 0
thousand: ",",
decimal: "."
}
};
var fillColors = [];
var strokePointHighColors = [];

View File

@@ -98,3 +98,18 @@ function currencySelect(e) {
return false;
}
// Settings object that controls default parameters for library methods:
accounting.settings = {
currency: {
symbol: currencySymbol, // default currency symbol is '$'
format: "%s %v", // controls output: %s = symbol, %v = value/number (can be object: see below)
decimal: mon_decimal_point, // decimal point separator
thousand: mon_thousands_sep, // thousands separator
precision: frac_digits // decimal places
},
number: {
precision: 0, // default precision on numbers is 0
thousand: ",",
decimal: "."
}
};

View File

@@ -0,0 +1,49 @@
/*
* from-store.js
* Copyright (C) 2016 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
/* globals globalSum */
$(function () {
"use strict";
$('.btn-do-split').click(cloneRow);
$('input[name="amount[]"]').on('input', calculateSum)
});
function cloneRow() {
"use strict";
var source = $('.initial-row').clone();
var count = $('.split-table tbody tr').length + 1;
source.removeClass('initial-row');
source.find('.count').text('#' + count);
source.find('input[name="amount[]"]').val("").on('input', calculateSum);
$('.split-table tbody').append(source);
calculateSum();
return false;
}
function calculateSum() {
"use strict";
var sum = 0;
var set = $('input[name="amount[]"]');
for (var i = 0; i < set.length; i++) {
var current = $(set[i]);
sum += (current.val() == "" ? 0 : parseFloat(current.val()));
}
console.log("Sum is now " + sum);
$('.amount-warning').remove();
if (sum != originalSum) {
console.log(sum + ' does not match ' + originalSum);
var holder = $('#amount_holder');
var par = holder.find('p.form-control-static');
var amount = $('<span>').text(' (' + accounting.formatMoney(sum) + ')').addClass('text-danger amount-warning').appendTo(par);
}
}