mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
minor fixes for profit/loss
This commit is contained in:
parent
8dd79fa176
commit
1ad3480f31
@ -26,14 +26,21 @@ class StoreBankTransactionRequest extends Request
|
||||
*/
|
||||
public function authorize() : bool
|
||||
{
|
||||
return auth()->user()->can('create', BankTransaction::class);
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
return $user->can('create', BankTransaction::class);
|
||||
}
|
||||
|
||||
public function rules()
|
||||
{
|
||||
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
$rules = [];
|
||||
|
||||
$rules['bank_integration_id'] = 'bail|required|exists:bank_integrations,id,company_id,'.auth()->user()->company()->id.',is_deleted,0';
|
||||
$rules['bank_integration_id'] = 'bail|required|exists:bank_integrations,id,company_id,'.$user->company()->id.',is_deleted,0';
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
@ -47,6 +47,9 @@ class BaseTransformer
|
||||
|
||||
public function parseDate($date)
|
||||
{
|
||||
if(stripos($date,"/") !== false && $this->company->settings->country_id != 840)
|
||||
$date = str_replace('/', '-', $date);
|
||||
|
||||
try {
|
||||
$parsed_date = Carbon::parse($date);
|
||||
|
||||
|
@ -11,8 +11,9 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Services\Bank\BankService;
|
||||
use App\Models\Expense;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use App\Services\Bank\BankService;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
/**
|
||||
@ -137,11 +138,6 @@ class BankTransaction extends BaseModel
|
||||
return $this->belongsTo(Vendor::class)->withTrashed();
|
||||
}
|
||||
|
||||
public function expense(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Expense::class)->withTrashed();
|
||||
}
|
||||
|
||||
public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class)->withTrashed();
|
||||
@ -162,8 +158,18 @@ class BankTransaction extends BaseModel
|
||||
return $this->belongsTo(Payment::class)->withTrashed();
|
||||
}
|
||||
|
||||
// public function expense(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
// {
|
||||
// return $this->belongsTo(Expense::class)->withTrashed();
|
||||
// }
|
||||
|
||||
public function service() :BankService
|
||||
{
|
||||
return new BankService($this);
|
||||
}
|
||||
|
||||
public function getExpenses()
|
||||
{
|
||||
return Expense::whereIn('id', $this->getExpenseIds())->get();
|
||||
}
|
||||
}
|
||||
|
@ -220,7 +220,7 @@ class Expense extends BaseModel
|
||||
|
||||
public function transaction(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(BankTransaction::class);
|
||||
return $this->belongsTo(BankTransaction::class)->withTrashed();
|
||||
}
|
||||
|
||||
public function stringStatus()
|
||||
|
@ -251,7 +251,7 @@ class Payment extends BaseModel
|
||||
|
||||
public function transaction(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(BankTransaction::class);
|
||||
return $this->belongsTo(BankTransaction::class)->withTrashed();
|
||||
}
|
||||
|
||||
public function exchange_currency(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
|
@ -38,11 +38,14 @@ class BankTransactionRepository extends BaseRepository
|
||||
|
||||
public function convert_matched($bank_transactions)
|
||||
{
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
$data['transactions'] = $bank_transactions->map(function ($bt) {
|
||||
return ['id' => $bt->id, 'invoice_ids' => $bt->invoice_ids, 'ninja_category_id' => $bt->ninja_category_id];
|
||||
})->toArray();
|
||||
|
||||
$bts = (new MatchBankTransactions(auth()->user()->company()->id, auth()->user()->company()->db, $data))->handle();
|
||||
$bts = (new MatchBankTransactions($user->company()->id, $user->company()->db, $data))->handle();
|
||||
}
|
||||
|
||||
public function unlink($bt)
|
||||
|
@ -67,9 +67,12 @@ class ExpenseRepository extends BaseRepository
|
||||
*/
|
||||
public function create($expense): ?Expense
|
||||
{
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
return $this->save(
|
||||
$expense,
|
||||
ExpenseFactory::create(auth()->user()->company()->id, auth()->user()->id)
|
||||
ExpenseFactory::create($user->company()->id, $user->id)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -355,7 +355,7 @@ class ProfitLoss
|
||||
|
||||
$csv->insertOne(['--------------------']);
|
||||
|
||||
$csv->insertOne([ctrans('texts.total_revenue'), Number::formatMoney($this->income - $this->income_taxes, $this->company)]);
|
||||
$csv->insertOne([ctrans('texts.total_revenue'), Number::formatMoney($this->income, $this->company)]);
|
||||
|
||||
//total taxes
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user