1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-18 00:53:10 +01:00

bug fixes

This commit is contained in:
Hillel Coren 2014-02-04 09:07:16 +02:00
parent 466a026adb
commit 2d23bb1e3e
5 changed files with 23 additions and 20 deletions

15
.gitignore vendored
View File

@ -10,10 +10,11 @@
/bootstrap/compiled.php /bootstrap/compiled.php
/bootstrap/environment.php /bootstrap/environment.php
/vendor /vendor
composer.phar /composer.phar
.DS_Store /.DS_Store
Thumbs.db /Thumbs.db
app.yaml /app.yaml
database.sql /database.sql
ninja.sublime-project /ninja.sublime-project
ninja.sublime-workspace /ninja.sublime-workspace
/tests/_log

View File

@ -48,7 +48,14 @@
var currency = currencies[i]; var currency = currencies[i];
currencyMap[currency.id] = currency; currencyMap[currency.id] = currency;
} }
var NINJA = {};
NINJA.parseFloat = function(str) {
if (!str) return '';
str = (str+'').replace(/[^0-9\.\-]/g, '');
return window.parseFloat(str);
}
function formatMoney(value, currency_id, hide_symbol) { function formatMoney(value, currency_id, hide_symbol) {
value = NINJA.parseFloat(value);
if (!currency_id) currency_id = {{ Session::get(SESSION_CURRENCY, DEFAULT_CURRENCY); }}; if (!currency_id) currency_id = {{ Session::get(SESSION_CURRENCY, DEFAULT_CURRENCY); }};
var currency = currencyMap[currency_id]; var currency = currencyMap[currency_id];
return accounting.formatMoney(value, hide_symbol ? '' : currency.symbol, currency.precision, currency.thousand_separator, currency.decimal_separator); return accounting.formatMoney(value, hide_symbol ? '' : currency.symbol, currency.precision, currency.thousand_separator, currency.decimal_separator);

View File

@ -1090,7 +1090,7 @@
var taxRate = parseFloat(self.tax_rate()); var taxRate = parseFloat(self.tax_rate());
if (taxRate > 0) { if (taxRate > 0) {
total = parseFloat(total) + (total * (taxRate/100)); total = NINJA.parseFloat(total) + (total * (taxRate/100));
} }
var paid = self.totals.rawPaidToDate(); var paid = self.totals.rawPaidToDate();
@ -1276,7 +1276,7 @@
this.prettyQty = ko.computed({ this.prettyQty = ko.computed({
read: function () { read: function () {
return parseFloat(this.qty()) ? parseFloat(this.qty()) : ''; return NINJA.parseFloat(this.qty()) ? NINJA.parseFloat(this.qty()) : '';
}, },
write: function (value) { write: function (value) {
this.qty(value); this.qty(value);
@ -1322,9 +1322,9 @@
this.totals = ko.observable(); this.totals = ko.observable();
this.totals.rawTotal = ko.computed(function() { this.totals.rawTotal = ko.computed(function() {
var cost = parseFloat(self.cost()); var cost = NINJA.parseFloat(self.cost());
var qty = parseFloat(self.qty()); var qty = NINJA.parseFloat(self.qty());
var taxRate = parseFloat(self.tax_rate()); var taxRate = NINJA.parseFloat(self.tax_rate());
var value = cost * qty; var value = cost * qty;
if (taxRate > 0) { if (taxRate > 0) {
value += value * (taxRate/100); value += value * (taxRate/100);
@ -1436,7 +1436,7 @@
for (var i=0; i<model.invoice().invoice_items().length; i++) { for (var i=0; i<model.invoice().invoice_items().length; i++) {
var item = model.invoice().invoice_items()[i]; var item = model.invoice().invoice_items()[i];
item.tax(model.getTaxRate(item.tax_name(), item.tax_rate())); item.tax(model.getTaxRate(item.tax_name(), item.tax_rate()));
item.cost(parseFloat(item.cost()) > 0 ? formatMoney(item.cost(), model.invoice().client().currency_id(), true) : ''); item.cost(NINJA.parseFloat(item.cost()) > 0 ? formatMoney(item.cost(), model.invoice().client().currency_id(), true) : '');
} }
onTaxRateChange(); onTaxRateChange();

View File

@ -5,7 +5,6 @@ var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Const
var isChrome = !!window.chrome && !isOpera; // Chrome 1+ var isChrome = !!window.chrome && !isOpera; // Chrome 1+
var isChromium = isChrome && navigator.userAgent.indexOf('Chromium') >= 0; var isChromium = isChrome && navigator.userAgent.indexOf('Chromium') >= 0;
var isIE = /*@cc_on!@*/false || !!document.documentMode; // At least IE6 var isIE = /*@cc_on!@*/false || !!document.documentMode; // At least IE6
var NINJA = {};
function generatePDF(invoice, checkMath) { function generatePDF(invoice, checkMath) {
var client = invoice.client; var client = invoice.client;
@ -380,11 +379,6 @@ function generatePDF(invoice, checkMath) {
return doc; return doc;
} }
NINJA.parseFloat = function(str) {
str = str.replace(/[^0-9\.\-]/g, '');
return window.parseFloat(str);
}
/* Handle converting variables in the invoices (ie, MONTH+1) */ /* Handle converting variables in the invoices (ie, MONTH+1) */

View File

@ -1,11 +1,12 @@
<?php <?php
$I = new WebGuy($scenario); $I = new WebGuy($scenario);
$I->wantTo('ensure that frontpage works'); $I->wantTo('click invoice now');
$I->amOnPage('/rocksteady'); $I->amOnPage('/rocksteady');
$I->click('#startButton'); $I->click('#startButton');
$I->seeInDatabase('users', ['id' => 1]); $I->seeInDatabase('users', ['id' => 1]);
$I->wantTo('create a client');
$I->click('#createClientLink'); $I->click('#createClientLink');
$I->fillField('input#email', 'test@aol.com'); $I->fillField('input#email', 'test@aol.com');
$I->click('#clientDoneButton'); $I->click('#clientDoneButton');