mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Resolved issue with expenses and multi-tenancy
This commit is contained in:
parent
2e17bac866
commit
a7f2d3354c
@ -153,7 +153,7 @@ class ExpenseController extends BaseController
|
||||
*/
|
||||
public function update(UpdateExpenseRequest $request)
|
||||
{
|
||||
$expense = $this->expenseRepo->save($request->input());
|
||||
$expense = $this->expenseService->save($request->input());
|
||||
|
||||
Session::flash('message', trans('texts.updated_expense'));
|
||||
|
||||
@ -167,7 +167,7 @@ class ExpenseController extends BaseController
|
||||
|
||||
public function store(CreateExpenseRequest $request)
|
||||
{
|
||||
$expense = $this->expenseRepo->save($request->input());
|
||||
$expense = $this->expenseService->save($request->input());
|
||||
|
||||
Session::flash('message', trans('texts.created_expense'));
|
||||
|
||||
|
@ -5,7 +5,8 @@ use Utils;
|
||||
use URL;
|
||||
use App\Services\BaseService;
|
||||
use App\Ninja\Repositories\ExpenseRepository;
|
||||
|
||||
use App\Models\Client;
|
||||
use App\Models\Vendor;
|
||||
|
||||
class ExpenseService extends BaseService
|
||||
{
|
||||
@ -26,6 +27,14 @@ class ExpenseService extends BaseService
|
||||
|
||||
public function save($data)
|
||||
{
|
||||
if (isset($data['client_id']) && $data['client_id']) {
|
||||
$data['client_id'] = Client::getPrivateId($data['client_id']);
|
||||
}
|
||||
|
||||
if (isset($data['vendor_id']) && $data['vendor_id']) {
|
||||
$data['vendor_id'] = Vendor::getPrivateId($data['vendor_id']);
|
||||
}
|
||||
|
||||
return $this->expenseRepo->save($data);
|
||||
}
|
||||
|
||||
|
@ -174,18 +174,19 @@
|
||||
var ViewModel = function(data) {
|
||||
var self = this;
|
||||
|
||||
self.client_id = ko.observable({{ $clientPublicId }});
|
||||
self.vendor_id = ko.observable({{ $vendorPublicId }});
|
||||
self.currency_id = ko.observable();
|
||||
self.amount = ko.observable();
|
||||
self.exchange_rate = ko.observable(1);
|
||||
self.should_be_invoiced = ko.observable();
|
||||
self.account_currency_id = ko.observable({{ $account->getCurrencyId() }});
|
||||
|
||||
if (data) {
|
||||
ko.mapping.fromJS(data, {}, this);
|
||||
}
|
||||
|
||||
self.account_currency_id = ko.observable({{ $account->getCurrencyId() }});
|
||||
self.client_id = ko.observable({{ $clientPublicId }});
|
||||
self.vendor_id = ko.observable({{ $vendorPublicId }});
|
||||
|
||||
self.convertedAmount = ko.computed({
|
||||
read: function () {
|
||||
return roundToTwo(self.amount() * self.exchange_rate()).toFixed(2);
|
||||
@ -204,7 +205,6 @@
|
||||
self.currencyName = ko.computed(function() {
|
||||
var currencyId = self.currency_id() || self.account_currency_id();
|
||||
var currency = currencyMap[currencyId];
|
||||
console.log(currencyId);
|
||||
return currency.name;
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user