mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Increased coverage and fixed a nasty bug.
This commit is contained in:
@@ -109,7 +109,6 @@ class AuthController extends Controller
|
||||
if (User::count() == 1) {
|
||||
$admin = Role::where('name', 'owner')->first();
|
||||
$this->auth->user()->attachRole($admin);
|
||||
// $this->auth->user()->roles()->save($admin);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -23,7 +23,7 @@ class NewUserController extends Controller
|
||||
/**
|
||||
* @param AccountRepositoryInterface $repository
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
* @@return \Illuminate\Http\RedirectResponse|\Illuminate\View\View
|
||||
*/
|
||||
public function index(AccountRepositoryInterface $repository)
|
||||
{
|
||||
@@ -45,6 +45,8 @@ class NewUserController extends Controller
|
||||
/**
|
||||
* @param NewUserFormRequest $request
|
||||
* @param AccountRepositoryInterface $repository
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function submit(NewUserFormRequest $request, AccountRepositoryInterface $repository)
|
||||
{
|
||||
@@ -97,20 +99,8 @@ class NewUserController extends Controller
|
||||
$creditCard = $repository->store($creditAccount);
|
||||
|
||||
// store meta for CC:
|
||||
AccountMeta::create(
|
||||
[
|
||||
'name' => 'ccType',
|
||||
'data' => 'monthlyFull',
|
||||
'account_id' => $creditCard->id,
|
||||
]
|
||||
);
|
||||
AccountMeta::create(
|
||||
[
|
||||
'name' => 'ccMonthlyPaymentDate',
|
||||
'data' => Carbon::now()->year . '-01-01',
|
||||
'account_id' => $creditCard->id,
|
||||
]
|
||||
);
|
||||
AccountMeta::create(['name' => 'ccType', 'data' => 'monthlyFull', 'account_id' => $creditCard->id,]);
|
||||
AccountMeta::create(['name' => 'ccMonthlyPaymentDate', 'data' => Carbon::now()->year . '-01-01', 'account_id' => $creditCard->id,]);
|
||||
|
||||
}
|
||||
Session::flash('success', 'New account(s) created!');
|
||||
|
@@ -46,7 +46,7 @@ use Watson\Validating\ValidatingTrait;
|
||||
* @property mixed lastActivityDate
|
||||
* @property mixed piggyBalance
|
||||
* @property mixed difference
|
||||
* @propery mixed percentage
|
||||
* @property mixed percentage
|
||||
*/
|
||||
class Account extends Model
|
||||
{
|
||||
|
@@ -68,7 +68,9 @@ use Watson\Validating\ValidatingTrait;
|
||||
* @property mixed account_id
|
||||
* @property mixed name
|
||||
* @property mixed symbol
|
||||
* @property-read mixed $correct_amount
|
||||
* @property-read mixed $correct_amount
|
||||
* @method static \FireflyIII\Models\TransactionJournal orderBy
|
||||
* @method static \FireflyIII\Models\TransactionJournal|null first
|
||||
*/
|
||||
class TransactionJournal extends Model
|
||||
{
|
||||
|
@@ -373,8 +373,9 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
*/
|
||||
public function openingBalanceTransaction(Account $account)
|
||||
{
|
||||
return TransactionJournal::accountIs($account)
|
||||
->orderBy('transaction_journals.date', 'ASC')
|
||||
return TransactionJournal
|
||||
::orderBy('transaction_journals.date', 'ASC')
|
||||
->accountIs($account)
|
||||
->orderBy('created_at', 'ASC')
|
||||
->first(['transaction_journals.*']);
|
||||
}
|
||||
|
@@ -75,14 +75,14 @@ class CategoryRepository implements CategoryRepositoryInterface
|
||||
->where('categories.user_id', Auth::user()->id)
|
||||
->after($start)
|
||||
->transactionTypes(['Withdrawal'])
|
||||
->groupBy('categories.id')
|
||||
->get(['categories.id as category_id', 'categories.encrypted as category_encrypted', 'categories.name', 'transaction_journals.*']);
|
||||
|
||||
$result = [];
|
||||
foreach ($set as $entry) {
|
||||
$categoryId = intval($entry->category_id);
|
||||
if (isset($result[$categoryId])) {
|
||||
$result[$categoryId]['sum'] += floatval($entry->amount);
|
||||
bcscale(2);
|
||||
$result[$categoryId]['sum'] = bcadd($result[$categoryId]['sum'], $entry->amount);
|
||||
} else {
|
||||
$isEncrypted = intval($entry->category_encrypted) == 1 ? true : false;
|
||||
$name = strlen($entry->name) == 0 ? trans('firefly.no_category') : $entry->name;
|
||||
|
Reference in New Issue
Block a user