diff --git a/app/database/seeds/ConstantsSeeder.php b/app/database/seeds/ConstantsSeeder.php index b519c7349f54..53e3a26cf6d8 100755 --- a/app/database/seeds/ConstantsSeeder.php +++ b/app/database/seeds/ConstantsSeeder.php @@ -138,6 +138,8 @@ class ConstantsSeeder extends Seeder Currency::create(array('name' => 'Norske Kroner', 'code' => 'NOK', 'symbol' => 'kr ', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.')); Currency::create(array('name' => 'New Zealand Dollar', 'code' => 'NZD', 'symbol' => '$', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.')); Currency::create(array('name' => 'Vietnamese Dong', 'code' => 'VND', 'symbol' => 'VND ', 'precision' => '0', 'thousand_separator' => ',', 'decimal_separator' => '.')); + Currency::create(array('name' => 'Swiss Franc', 'code' => 'CHF', 'symbol' => 'CHF ', 'precision' => '2', 'thousand_separator' => '\'', 'decimal_separator' => '.')); + DatetimeFormat::create(array('format' => 'd/M/Y g:i a', 'label' => '10/Mar/2013')); DatetimeFormat::create(array('format' => 'd-M-Yk g:i a', 'label' => '10-Mar-2013')); diff --git a/app/views/invoices/edit.blade.php b/app/views/invoices/edit.blade.php index f9e489f03e08..23fe8a302892 100755 --- a/app/views/invoices/edit.blade.php +++ b/app/views/invoices/edit.blade.php @@ -1201,60 +1201,60 @@ }); this.totals.total = ko.computed(function() { - var total = accounting.toFixed(self.totals.rawSubtotal(),2); - var discount = self.totals.rawDiscounted(); - total -= discount; + var total = accounting.toFixed(self.totals.rawSubtotal(),2); + var discount = self.totals.rawDiscounted(); + total -= discount; - /* - var discount = parseFloat(self.discount()); - if (discount > 0) { - total = roundToTwo(total * ((100 - discount)/100)); - } - */ + /* + var discount = parseFloat(self.discount()); + if (discount > 0) { + total = roundToTwo(total * ((100 - discount)/100)); + } + */ - var customValue1 = roundToTwo(self.custom_value1()); - var customValue2 = roundToTwo(self.custom_value2()); - var customTaxes1 = self.custom_taxes1() == 1; - var customTaxes2 = self.custom_taxes2() == 1; - - if (customValue1 && customTaxes1) { - total = NINJA.parseFloat(total) + customValue1; - } - if (customValue2 && customTaxes2) { - total = NINJA.parseFloat(total) + customValue2; - } + var customValue1 = roundToTwo(self.custom_value1()); + var customValue2 = roundToTwo(self.custom_value2()); + var customTaxes1 = self.custom_taxes1() == 1; + var customTaxes2 = self.custom_taxes2() == 1; + + if (customValue1 && customTaxes1) { + total = NINJA.parseFloat(total) + customValue1; + } + if (customValue2 && customTaxes2) { + total = NINJA.parseFloat(total) + customValue2; + } - var taxRate = parseFloat(self.tax_rate()); - if (taxRate > 0) { - total = NINJA.parseFloat(total) + roundToTwo((total * (taxRate/100))); - } + var taxRate = parseFloat(self.tax_rate()); + if (taxRate > 0) { + total = NINJA.parseFloat(total) + roundToTwo((total * (taxRate/100))); + } - if (customValue1 && !customTaxes1) { - total = NINJA.parseFloat(total) + customValue1; - } - if (customValue2 && !customTaxes2) { - total = NINJA.parseFloat(total) + customValue2; - } - - var paid = self.totals.rawPaidToDate(); - if (paid > 0) { - total -= paid; - } + if (customValue1 && !customTaxes1) { + total = NINJA.parseFloat(total) + customValue1; + } + if (customValue2 && !customTaxes2) { + total = NINJA.parseFloat(total) + customValue2; + } + + var paid = self.totals.rawPaidToDate(); + if (paid > 0) { + total -= paid; + } - return formatMoney(total, self.client().currency_id()); - }); + return formatMoney(total, self.client().currency_id()); + }); - self.onDragged = function(item) { - refreshPDF(); - } + self.onDragged = function(item) { + refreshPDF(); + } } function ClientModel(data) { var self = this; self.public_id = ko.observable(0); self.name = ko.observable(''); - self.id_number = ko.observable(''); - self.vat_number = ko.observable(''); + self.id_number = ko.observable(''); + self.vat_number = ko.observable(''); self.work_phone = ko.observable(''); self.custom_value1 = ko.observable(''); self.custom_value2 = ko.observable(''); diff --git a/public/built.js b/public/built.js index 0d73f40ecede..e0e22a4ecd81 100644 --- a/public/built.js +++ b/public/built.js @@ -33024,7 +33024,7 @@ function toggleDatePicker(field) { function roundToTwo(num, toString) { var val = +(Math.round(num + "e+2") + "e-2"); - return toString ? val.toFixed(2) : val; + return toString ? val.toFixed(2) : val || 0; } function truncate(str, length) { diff --git a/public/js/script.js b/public/js/script.js index 1c99d557bc75..e5c1f27dbfc1 100644 --- a/public/js/script.js +++ b/public/js/script.js @@ -1501,7 +1501,7 @@ function toggleDatePicker(field) { function roundToTwo(num, toString) { var val = +(Math.round(num + "e+2") + "e-2"); - return toString ? val.toFixed(2) : val; + return toString ? val.toFixed(2) : (val || 0); } function truncate(str, length) {