mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Bug fixes
This commit is contained in:
parent
c9b7f79d7c
commit
3688669963
@ -86,7 +86,7 @@ class AccountController extends \BaseController {
|
|||||||
'account' => Account::with('users')->findOrFail(Auth::user()->account_id),
|
'account' => Account::with('users')->findOrFail(Auth::user()->account_id),
|
||||||
'countries' => Country::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
|
'countries' => Country::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
|
||||||
'sizes' => Size::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(),
|
'sizes' => Size::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(),
|
||||||
'industries' => Industry::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(),
|
'industries' => Industry::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
|
||||||
'timezones' => Timezone::remember(DEFAULT_QUERY_CACHE)->orderBy('location')->get(),
|
'timezones' => Timezone::remember(DEFAULT_QUERY_CACHE)->orderBy('location')->get(),
|
||||||
'dateFormats' => DateFormat::remember(DEFAULT_QUERY_CACHE)->get(),
|
'dateFormats' => DateFormat::remember(DEFAULT_QUERY_CACHE)->get(),
|
||||||
'datetimeFormats' => DatetimeFormat::remember(DEFAULT_QUERY_CACHE)->get(),
|
'datetimeFormats' => DatetimeFormat::remember(DEFAULT_QUERY_CACHE)->get(),
|
||||||
|
@ -154,7 +154,7 @@ class ClientController extends \BaseController {
|
|||||||
return [
|
return [
|
||||||
'sizes' => Size::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(),
|
'sizes' => Size::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(),
|
||||||
'paymentTerms' => PaymentTerm::remember(DEFAULT_QUERY_CACHE)->orderBy('num_days')->get(['name', 'num_days']),
|
'paymentTerms' => PaymentTerm::remember(DEFAULT_QUERY_CACHE)->orderBy('num_days')->get(['name', 'num_days']),
|
||||||
'industries' => Industry::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(),
|
'industries' => Industry::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
|
||||||
'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
|
'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
|
||||||
'countries' => Country::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
|
'countries' => Country::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
|
||||||
'customLabel1' => Auth::user()->account->custom_client_label1,
|
'customLabel1' => Auth::user()->account->custom_client_label1,
|
||||||
|
@ -241,7 +241,7 @@ class InvoiceController extends \BaseController {
|
|||||||
'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
|
'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
|
||||||
'sizes' => Size::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(),
|
'sizes' => Size::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(),
|
||||||
'paymentTerms' => PaymentTerm::remember(DEFAULT_QUERY_CACHE)->orderBy('num_days')->get(['name', 'num_days']),
|
'paymentTerms' => PaymentTerm::remember(DEFAULT_QUERY_CACHE)->orderBy('num_days')->get(['name', 'num_days']),
|
||||||
'industries' => Industry::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(),
|
'industries' => Industry::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
|
||||||
'invoiceDesigns' => InvoiceDesign::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(),
|
'invoiceDesigns' => InvoiceDesign::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(),
|
||||||
'invoiceLabels' => Auth::user()->account->getInvoiceLabels(),
|
'invoiceLabels' => Auth::user()->account->getInvoiceLabels(),
|
||||||
'frequencies' => array(
|
'frequencies' => array(
|
||||||
|
@ -94,7 +94,7 @@ class QuoteController extends \BaseController {
|
|||||||
'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
|
'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
|
||||||
'sizes' => Size::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(),
|
'sizes' => Size::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(),
|
||||||
'paymentTerms' => PaymentTerm::remember(DEFAULT_QUERY_CACHE)->orderBy('num_days')->get(['name', 'num_days']),
|
'paymentTerms' => PaymentTerm::remember(DEFAULT_QUERY_CACHE)->orderBy('num_days')->get(['name', 'num_days']),
|
||||||
'industries' => Industry::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(),
|
'industries' => Industry::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
|
||||||
'invoiceDesigns' => InvoiceDesign::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(),
|
'invoiceDesigns' => InvoiceDesign::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(),
|
||||||
'invoiceLabels' => Auth::user()->account->getInvoiceLabels()
|
'invoiceLabels' => Auth::user()->account->getInvoiceLabels()
|
||||||
];
|
];
|
||||||
|
@ -105,6 +105,7 @@ class ConstantsSeeder extends Seeder
|
|||||||
Industry::create(array('name' => 'Transportation'));
|
Industry::create(array('name' => 'Transportation'));
|
||||||
Industry::create(array('name' => 'Travel & Luxury'));
|
Industry::create(array('name' => 'Travel & Luxury'));
|
||||||
Industry::create(array('name' => 'Other'));
|
Industry::create(array('name' => 'Other'));
|
||||||
|
Industry::create(array('name' => 'Photography'));
|
||||||
|
|
||||||
Size::create(array('name' => '1 - 3'));
|
Size::create(array('name' => '1 - 3'));
|
||||||
Size::create(array('name' => '4 - 10'));
|
Size::create(array('name' => '4 - 10'));
|
||||||
@ -119,6 +120,7 @@ class ConstantsSeeder extends Seeder
|
|||||||
PaymentTerm::create(array('num_days' => 15, 'name' => 'Net 15'));
|
PaymentTerm::create(array('num_days' => 15, 'name' => 'Net 15'));
|
||||||
PaymentTerm::create(array('num_days' => 30, 'name' => 'Net 30'));
|
PaymentTerm::create(array('num_days' => 30, 'name' => 'Net 30'));
|
||||||
PaymentTerm::create(array('num_days' => 60, 'name' => 'Net 60'));
|
PaymentTerm::create(array('num_days' => 60, 'name' => 'Net 60'));
|
||||||
|
PaymentTerm::create(array('num_days' => 90, 'name' => 'Net 90'));
|
||||||
|
|
||||||
Currency::create(array('name' => 'US Dollar', 'code' => 'USD', 'symbol' => '$', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'));
|
Currency::create(array('name' => 'US Dollar', 'code' => 'USD', 'symbol' => '$', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'));
|
||||||
Currency::create(array('name' => 'Pound Sterling', 'code' => 'GBP', 'symbol' => '£', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'));
|
Currency::create(array('name' => 'Pound Sterling', 'code' => 'GBP', 'symbol' => '£', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'));
|
||||||
|
@ -251,7 +251,8 @@ class InvoiceRepository
|
|||||||
}
|
}
|
||||||
|
|
||||||
$lineTotal = $invoiceItemCost * $invoiceItemQty;
|
$lineTotal = $invoiceItemCost * $invoiceItemQty;
|
||||||
$total += $lineTotal + ($lineTotal * $invoiceItemTaxRate / 100);
|
|
||||||
|
$total += round($lineTotal + ($lineTotal * $invoiceItemTaxRate / 100), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($invoice->discount > 0)
|
if ($invoice->discount > 0)
|
||||||
@ -260,6 +261,7 @@ class InvoiceRepository
|
|||||||
}
|
}
|
||||||
|
|
||||||
$total += $total * $invoice->tax_rate / 100;
|
$total += $total * $invoice->tax_rate / 100;
|
||||||
|
$total = round($total, 2);
|
||||||
|
|
||||||
if ($publicId)
|
if ($publicId)
|
||||||
{
|
{
|
||||||
|
@ -1095,7 +1095,7 @@
|
|||||||
var total = 0;
|
var total = 0;
|
||||||
for(var p=0; p < self.invoice_items().length; ++p) {
|
for(var p=0; p < self.invoice_items().length; ++p) {
|
||||||
var item = self.invoice_items()[p];
|
var item = self.invoice_items()[p];
|
||||||
total += item.totals.rawTotal();
|
total += item.totals.rawTotal();
|
||||||
}
|
}
|
||||||
return total;
|
return total;
|
||||||
});
|
});
|
||||||
@ -1106,7 +1106,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.totals.rawDiscounted = ko.computed(function() {
|
this.totals.rawDiscounted = ko.computed(function() {
|
||||||
return self.totals.rawSubtotal() * (self.discount()/100);
|
return roundToTwo(self.totals.rawSubtotal() * (self.discount()/100));
|
||||||
});
|
});
|
||||||
|
|
||||||
this.totals.discounted = ko.computed(function() {
|
this.totals.discounted = ko.computed(function() {
|
||||||
@ -1118,12 +1118,12 @@
|
|||||||
|
|
||||||
var discount = parseFloat(self.discount());
|
var discount = parseFloat(self.discount());
|
||||||
if (discount > 0) {
|
if (discount > 0) {
|
||||||
total = total * ((100 - discount)/100);
|
total = roundToTwo(total * ((100 - discount)/100));
|
||||||
}
|
}
|
||||||
|
|
||||||
var taxRate = parseFloat(self.tax_rate());
|
var taxRate = parseFloat(self.tax_rate());
|
||||||
if (taxRate > 0) {
|
if (taxRate > 0) {
|
||||||
var tax = total * (taxRate/100);
|
var tax = roundToTwo(total * (taxRate/100));
|
||||||
return formatMoney(tax, self.client().currency_id());
|
return formatMoney(tax, self.client().currency_id());
|
||||||
} else {
|
} else {
|
||||||
return formatMoney(0);
|
return formatMoney(0);
|
||||||
@ -1140,29 +1140,29 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.totals.total = ko.computed(function() {
|
this.totals.total = ko.computed(function() {
|
||||||
var total = accounting.toFixed(self.totals.rawSubtotal(),2);
|
var total = accounting.toFixed(self.totals.rawSubtotal(),2);
|
||||||
|
|
||||||
var discount = parseFloat(self.discount());
|
var discount = parseFloat(self.discount());
|
||||||
if (discount > 0) {
|
if (discount > 0) {
|
||||||
total = total * ((100 - discount)/100);
|
total = roundToTwo(total * ((100 - discount)/100));
|
||||||
}
|
}
|
||||||
|
|
||||||
var taxRate = parseFloat(self.tax_rate());
|
var taxRate = parseFloat(self.tax_rate());
|
||||||
if (taxRate > 0) {
|
if (taxRate > 0) {
|
||||||
total = NINJA.parseFloat(total) + (total * (taxRate/100));
|
total = NINJA.parseFloat(total) + roundToTwo((total * (taxRate/100)));
|
||||||
}
|
}
|
||||||
|
|
||||||
var paid = self.totals.rawPaidToDate();
|
var paid = self.totals.rawPaidToDate();
|
||||||
if (paid > 0) {
|
if (paid > 0) {
|
||||||
total -= paid;
|
total -= paid;
|
||||||
}
|
}
|
||||||
|
|
||||||
return total != 0 ? formatMoney(total, self.client().currency_id()) : '';
|
return total != 0 ? formatMoney(total, self.client().currency_id()) : '';
|
||||||
});
|
});
|
||||||
|
|
||||||
self.onDragged = function(item) {
|
self.onDragged = function(item) {
|
||||||
refreshPDF();
|
refreshPDF();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function ClientModel(data) {
|
function ClientModel(data) {
|
||||||
@ -1392,12 +1392,12 @@
|
|||||||
var cost = NINJA.parseFloat(self.cost());
|
var cost = NINJA.parseFloat(self.cost());
|
||||||
var qty = NINJA.parseFloat(self.qty());
|
var qty = NINJA.parseFloat(self.qty());
|
||||||
var taxRate = NINJA.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);
|
||||||
}
|
}
|
||||||
return value ? value : '';
|
return value ? roundToTwo(value) : '';
|
||||||
});
|
});
|
||||||
|
|
||||||
this.totals.total = ko.computed(function() {
|
this.totals.total = ko.computed(function() {
|
||||||
var total = self.totals.rawTotal();
|
var total = self.totals.rawTotal();
|
||||||
@ -1406,22 +1406,22 @@
|
|||||||
} else {
|
} else {
|
||||||
return total ? formatMoney(total, 1) : '';
|
return total ? formatMoney(total, 1) : '';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.hideActions = function() {
|
this.hideActions = function() {
|
||||||
this.actionsVisible(false);
|
this.actionsVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.showActions = function() {
|
this.showActions = function() {
|
||||||
this.actionsVisible(true);
|
this.actionsVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.isEmpty = function() {
|
this.isEmpty = function() {
|
||||||
return !self.product_key() && !self.notes() && !self.cost() && !self.qty();
|
return !self.product_key() && !self.notes() && !self.cost() && !self.qty();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.onSelect = function(){
|
this.onSelect = function(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onItemChange()
|
function onItemChange()
|
||||||
|
@ -39195,7 +39195,7 @@ function calculateAmounts(invoice) {
|
|||||||
|
|
||||||
var lineTotal = NINJA.parseFloat(item.cost) * NINJA.parseFloat(item.qty);
|
var lineTotal = NINJA.parseFloat(item.cost) * NINJA.parseFloat(item.qty);
|
||||||
if (tax) {
|
if (tax) {
|
||||||
lineTotal += lineTotal * tax / 100;
|
lineTotal += roundToTwo(lineTotal * tax / 100);
|
||||||
}
|
}
|
||||||
if (lineTotal) {
|
if (lineTotal) {
|
||||||
total += lineTotal;
|
total += lineTotal;
|
||||||
@ -39210,7 +39210,7 @@ function calculateAmounts(invoice) {
|
|||||||
|
|
||||||
if (invoice.discount > 0) {
|
if (invoice.discount > 0) {
|
||||||
|
|
||||||
var discount = total * (invoice.discount/100);
|
var discount = roundToTwo(total * (invoice.discount/100));
|
||||||
total -= discount;
|
total -= discount;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39219,14 +39219,14 @@ function calculateAmounts(invoice) {
|
|||||||
tax = parseFloat(invoice.tax.rate);
|
tax = parseFloat(invoice.tax.rate);
|
||||||
} else if (invoice.tax_rate && parseFloat(invoice.tax_rate)) {
|
} else if (invoice.tax_rate && parseFloat(invoice.tax_rate)) {
|
||||||
tax = parseFloat(invoice.tax_rate);
|
tax = parseFloat(invoice.tax_rate);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tax) {
|
if (tax) {
|
||||||
var tax = total * (tax/100);
|
var tax = roundToTwo(total * (tax/100));
|
||||||
total = parseFloat(total) + parseFloat(tax);
|
total = parseFloat(total) + parseFloat(tax);
|
||||||
}
|
}
|
||||||
|
|
||||||
invoice.balance_amount = accounting.toFixed(total,2) - (accounting.toFixed(invoice.amount,2) - accounting.toFixed(invoice.balance,2));
|
invoice.balance_amount = roundToTwo(total) - roundToTwo(invoice.amount) - roundToTwo(invoice.balance);
|
||||||
invoice.tax_amount = tax;
|
invoice.tax_amount = tax;
|
||||||
invoice.discount_amount = discount;
|
invoice.discount_amount = discount;
|
||||||
invoice.has_taxes = hasTaxes;
|
invoice.has_taxes = hasTaxes;
|
||||||
@ -39463,3 +39463,6 @@ function toggleDatePicker(field) {
|
|||||||
$('#'+field).datepicker('show');
|
$('#'+field).datepicker('show');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function roundToTwo(num) {
|
||||||
|
return +(Math.round(num + "e+2") + "e-2");
|
||||||
|
}
|
||||||
|
@ -1479,7 +1479,7 @@ function calculateAmounts(invoice) {
|
|||||||
|
|
||||||
var lineTotal = NINJA.parseFloat(item.cost) * NINJA.parseFloat(item.qty);
|
var lineTotal = NINJA.parseFloat(item.cost) * NINJA.parseFloat(item.qty);
|
||||||
if (tax) {
|
if (tax) {
|
||||||
lineTotal += lineTotal * tax / 100;
|
lineTotal += roundToTwo(lineTotal * tax / 100);
|
||||||
}
|
}
|
||||||
if (lineTotal) {
|
if (lineTotal) {
|
||||||
total += lineTotal;
|
total += lineTotal;
|
||||||
@ -1494,7 +1494,7 @@ function calculateAmounts(invoice) {
|
|||||||
|
|
||||||
if (invoice.discount > 0) {
|
if (invoice.discount > 0) {
|
||||||
|
|
||||||
var discount = total * (invoice.discount/100);
|
var discount = roundToTwo(total * (invoice.discount/100));
|
||||||
total -= discount;
|
total -= discount;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1503,14 +1503,14 @@ function calculateAmounts(invoice) {
|
|||||||
tax = parseFloat(invoice.tax.rate);
|
tax = parseFloat(invoice.tax.rate);
|
||||||
} else if (invoice.tax_rate && parseFloat(invoice.tax_rate)) {
|
} else if (invoice.tax_rate && parseFloat(invoice.tax_rate)) {
|
||||||
tax = parseFloat(invoice.tax_rate);
|
tax = parseFloat(invoice.tax_rate);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tax) {
|
if (tax) {
|
||||||
var tax = total * (tax/100);
|
var tax = roundToTwo(total * (tax/100));
|
||||||
total = parseFloat(total) + parseFloat(tax);
|
total = parseFloat(total) + parseFloat(tax);
|
||||||
}
|
}
|
||||||
|
|
||||||
invoice.balance_amount = accounting.toFixed(total,2) - (accounting.toFixed(invoice.amount,2) - accounting.toFixed(invoice.balance,2));
|
invoice.balance_amount = roundToTwo(total) - roundToTwo(invoice.amount) - roundToTwo(invoice.balance);
|
||||||
invoice.tax_amount = tax;
|
invoice.tax_amount = tax;
|
||||||
invoice.discount_amount = discount;
|
invoice.discount_amount = discount;
|
||||||
invoice.has_taxes = hasTaxes;
|
invoice.has_taxes = hasTaxes;
|
||||||
@ -1747,3 +1747,6 @@ function toggleDatePicker(field) {
|
|||||||
$('#'+field).datepicker('show');
|
$('#'+field).datepicker('show');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function roundToTwo(num) {
|
||||||
|
return +(Math.round(num + "e+2") + "e-2");
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user