mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Made expense currency conversion hidden by default
This commit is contained in:
parent
ee516cb327
commit
eac4c823d3
@ -76,19 +76,9 @@ class Expense extends EntityModel
|
|||||||
return ENTITY_EXPENSE;
|
return ENTITY_EXPENSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function apply($amount)
|
public function isExchanged()
|
||||||
{
|
{
|
||||||
if ($amount > $this->balance) {
|
return $this->invoice_currency_id != $this->expense_currency_id;
|
||||||
$applied = $this->balance;
|
|
||||||
$this->balance = 0;
|
|
||||||
} else {
|
|
||||||
$applied = $amount;
|
|
||||||
$this->balance = $this->balance - $amount;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->save();
|
|
||||||
|
|
||||||
return $applied;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1150,5 +1150,6 @@ return array(
|
|||||||
'trial_success' => 'Successfully enabled two week free pro plan trial',
|
'trial_success' => 'Successfully enabled two week free pro plan trial',
|
||||||
'overdue' => 'Overdue',
|
'overdue' => 'Overdue',
|
||||||
'white_label_text' => 'Purchase a ONE YEAR white label license for $'.WHITE_LABEL_PRICE.' to remove the Invoice Ninja branding from the client portal and help support our project.',
|
'white_label_text' => 'Purchase a ONE YEAR white label license for $'.WHITE_LABEL_PRICE.' to remove the Invoice Ninja branding from the client portal and help support our project.',
|
||||||
|
|
||||||
|
'convert_currency' => 'Convert currency',
|
||||||
);
|
);
|
||||||
|
@ -63,36 +63,46 @@
|
|||||||
{!! Former::checkbox('should_be_invoiced')
|
{!! Former::checkbox('should_be_invoiced')
|
||||||
->text(trans('texts.should_be_invoiced'))
|
->text(trans('texts.should_be_invoiced'))
|
||||||
->data_bind('checked: should_be_invoiced() || client_id(), enable: !client_id()')
|
->data_bind('checked: should_be_invoiced() || client_id(), enable: !client_id()')
|
||||||
->label(' ') !!}<br/>
|
->label(' ') !!}
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
<span style="display:none" data-bind="visible: !client_id()">
|
@if (!$expense || ($expense && ! $expense->isExchanged()))
|
||||||
{!! Former::select('invoice_currency_id')->addOption('','')
|
{!! Former::checkbox('convert_currency')
|
||||||
->label(trans('texts.invoice_currency'))
|
->text(trans('texts.convert_currency'))
|
||||||
->data_placeholder(Utils::getFromCache($account->getCurrencyId(), 'currencies')->name)
|
->data_bind('checked: convert_currency')
|
||||||
->data_bind('combobox: invoice_currency_id, disable: true')
|
->label(' ') !!}
|
||||||
->fromQuery($currencies, 'name', 'id') !!}
|
@endif
|
||||||
</span>
|
<br/>
|
||||||
<span style="display:none;" data-bind="visible: client_id">
|
|
||||||
{!! Former::plaintext('test')
|
|
||||||
->value('<span data-bind="html: invoiceCurrencyName"></span>')
|
|
||||||
->style('min-height:46px')
|
|
||||||
->label(trans('texts.invoice_currency')) !!}
|
|
||||||
</span>
|
|
||||||
|
|
||||||
{!! Former::text('exchange_rate')
|
<div style="display:none" data-bind="visible: enableExchangeRate">
|
||||||
->data_bind("value: exchange_rate, enable: enableExchangeRate, valueUpdate: 'afterkeydown'") !!}
|
<span style="display:none" data-bind="visible: !client_id()">
|
||||||
|
{!! Former::select('invoice_currency_id')->addOption('','')
|
||||||
|
->label(trans('texts.invoice_currency'))
|
||||||
|
->data_placeholder(Utils::getFromCache($account->getCurrencyId(), 'currencies')->name)
|
||||||
|
->data_bind('combobox: invoice_currency_id, disable: true')
|
||||||
|
->fromQuery($currencies, 'name', 'id') !!}
|
||||||
|
</span>
|
||||||
|
<span style="display:none;" data-bind="visible: client_id">
|
||||||
|
{!! Former::plaintext('test')
|
||||||
|
->value('<span data-bind="html: invoiceCurrencyName"></span>')
|
||||||
|
->style('min-height:46px')
|
||||||
|
->label(trans('texts.invoice_currency')) !!}
|
||||||
|
</span>
|
||||||
|
|
||||||
{!! Former::text('invoice_amount')
|
{!! Former::text('exchange_rate')
|
||||||
->addGroupClass('converted-amount')
|
->data_bind("value: exchange_rate, enable: enableExchangeRate, valueUpdate: 'afterkeydown'") !!}
|
||||||
->data_bind("value: convertedAmount, enable: enableExchangeRate")
|
|
||||||
->append('<span data-bind="html: invoiceCurrencyCode"></span>') !!}
|
|
||||||
|
|
||||||
|
{!! Former::text('invoice_amount')
|
||||||
|
->addGroupClass('converted-amount')
|
||||||
|
->data_bind("value: convertedAmount, enable: enableExchangeRate")
|
||||||
|
->append('<span data-bind="html: invoiceCurrencyCode"></span>') !!}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
|
|
||||||
{!! Former::textarea('public_notes')->style('height:255px') !!}
|
{!! Former::textarea('public_notes')->rows(8) !!}
|
||||||
{!! Former::textarea('private_notes')->style('height:255px') !!}
|
{!! Former::textarea('private_notes')->rows(8) !!}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -194,6 +204,7 @@
|
|||||||
self.amount = ko.observable();
|
self.amount = ko.observable();
|
||||||
self.exchange_rate = ko.observable(1);
|
self.exchange_rate = ko.observable(1);
|
||||||
self.should_be_invoiced = ko.observable();
|
self.should_be_invoiced = ko.observable();
|
||||||
|
self.convert_currency = ko.observable(false);
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
ko.mapping.fromJS(data, {}, this);
|
ko.mapping.fromJS(data, {}, this);
|
||||||
@ -230,9 +241,14 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
self.enableExchangeRate = ko.computed(function() {
|
self.enableExchangeRate = ko.computed(function() {
|
||||||
|
if (self.convert_currency()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
var expenseCurrencyId = self.expense_currency_id() || self.account_currency_id();
|
var expenseCurrencyId = self.expense_currency_id() || self.account_currency_id();
|
||||||
var invoiceCurrencyId = self.invoice_currency_id() || self.account_currency_id();
|
var invoiceCurrencyId = self.invoice_currency_id() || self.account_currency_id();
|
||||||
return expenseCurrencyId != invoiceCurrencyId;
|
return expenseCurrencyId != invoiceCurrencyId
|
||||||
|
|| invoiceCurrencyId != self.account_currency_id()
|
||||||
|
|| expenseCurrencyId != self.account_currency_id();
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user