|
@@ -4,6 +4,7 @@ use App\Enums\Accounting\JournalEntryType;
|
4
|
4
|
use App\Enums\Accounting\TransactionType;
|
5
|
5
|
use App\Filament\Company\Resources\Accounting\TransactionResource\Pages\ListTransactions;
|
6
|
6
|
use App\Filament\Forms\Components\JournalEntryRepeater;
|
|
7
|
+use App\Filament\Tables\Actions\EditTransactionAction;
|
7
|
8
|
use App\Filament\Tables\Actions\ReplicateBulkAction;
|
8
|
9
|
use App\Models\Accounting\Account;
|
9
|
10
|
use App\Models\Accounting\Transaction;
|
|
@@ -254,8 +255,8 @@ it('can add an income or expense transaction', function (TransactionType $transa
|
254
|
255
|
->account->is($defaultAccount)->toBeTrue()
|
255
|
256
|
->journalEntries->count()->toBe(2);
|
256
|
257
|
})->with([
|
257
|
|
- [TransactionType::Deposit, 'addIncome'],
|
258
|
|
- [TransactionType::Withdrawal, 'addExpense'],
|
|
258
|
+ [TransactionType::Deposit, 'createDeposit'],
|
|
259
|
+ [TransactionType::Withdrawal, 'createWithdrawal'],
|
259
|
260
|
]);
|
260
|
261
|
|
261
|
262
|
it('can add a transfer transaction', function () {
|
|
@@ -264,7 +265,7 @@ it('can add a transfer transaction', function () {
|
264
|
265
|
$destinationBankAccount = Account::factory()->withBankAccount('Destination Bank Account')->create();
|
265
|
266
|
|
266
|
267
|
livewire(ListTransactions::class)
|
267
|
|
- ->mountAction('addTransfer')
|
|
268
|
+ ->mountAction('createTransfer')
|
268
|
269
|
->assertActionDataSet([
|
269
|
270
|
'posted_at' => today(),
|
270
|
271
|
'type' => TransactionType::Transfer,
|
|
@@ -297,7 +298,7 @@ it('can add a journal transaction', function () {
|
297
|
298
|
$undoRepeaterFake = JournalEntryRepeater::fake();
|
298
|
299
|
|
299
|
300
|
livewire(ListTransactions::class)
|
300
|
|
- ->mountAction('addJournalEntry')
|
|
301
|
+ ->mountAction('createJournalEntry')
|
301
|
302
|
->assertActionDataSet([
|
302
|
303
|
'posted_at' => today(),
|
303
|
304
|
'journalEntries' => [
|
|
@@ -345,7 +346,7 @@ it('can update a deposit or withdrawal transaction', function (TransactionType $
|
345
|
346
|
$newDescription = 'Updated Description';
|
346
|
347
|
|
347
|
348
|
livewire(ListTransactions::class)
|
348
|
|
- ->mountTableAction('editTransaction', $transaction)
|
|
349
|
+ ->mountTableAction(EditTransactionAction::class, $transaction)
|
349
|
350
|
->assertTableActionDataSet([
|
350
|
351
|
'type' => $transactionType->value,
|
351
|
352
|
'description' => $transaction->description,
|
|
@@ -367,23 +368,6 @@ it('can update a deposit or withdrawal transaction', function (TransactionType $
|
367
|
368
|
TransactionType::Withdrawal,
|
368
|
369
|
]);
|
369
|
370
|
|
370
|
|
-it('does not show Edit Transfer or Edit Journal Transaction for deposit or withdrawal transactions', function (TransactionType $transactionType) {
|
371
|
|
- $defaultAccount = Transaction::getUncategorizedAccountByType($transactionType);
|
372
|
|
-
|
373
|
|
- $transaction = Transaction::factory()
|
374
|
|
- ->forDefaultBankAccount()
|
375
|
|
- ->forAccount($defaultAccount)
|
376
|
|
- ->forType($transactionType, 1000)
|
377
|
|
- ->create();
|
378
|
|
-
|
379
|
|
- livewire(ListTransactions::class)
|
380
|
|
- ->assertTableActionHidden('editTransfer', $transaction)
|
381
|
|
- ->assertTableActionHidden('editJournalEntry', $transaction);
|
382
|
|
-})->with([
|
383
|
|
- TransactionType::Deposit,
|
384
|
|
- TransactionType::Withdrawal,
|
385
|
|
-]);
|
386
|
|
-
|
387
|
371
|
it('can update a transfer transaction', function () {
|
388
|
372
|
$transaction = Transaction::factory()
|
389
|
373
|
->forDefaultBankAccount()
|
|
@@ -394,7 +378,7 @@ it('can update a transfer transaction', function () {
|
394
|
378
|
$newDescription = 'Updated Transfer Description';
|
395
|
379
|
|
396
|
380
|
livewire(ListTransactions::class)
|
397
|
|
- ->mountTableAction('editTransfer', $transaction)
|
|
381
|
+ ->mountTableAction(EditTransactionAction::class, $transaction)
|
398
|
382
|
->assertTableActionDataSet([
|
399
|
383
|
'type' => TransactionType::Transfer->value,
|
400
|
384
|
'description' => $transaction->description,
|
|
@@ -413,18 +397,6 @@ it('can update a transfer transaction', function () {
|
413
|
397
|
->and($transaction->amount)->toEqual('2,000.00');
|
414
|
398
|
});
|
415
|
399
|
|
416
|
|
-it('does not show Edit Transaction or Edit Journal Transaction for transfer transactions', function () {
|
417
|
|
- $transaction = Transaction::factory()
|
418
|
|
- ->forDefaultBankAccount()
|
419
|
|
- ->forDestinationBankAccount()
|
420
|
|
- ->asTransfer(1500)
|
421
|
|
- ->create();
|
422
|
|
-
|
423
|
|
- livewire(ListTransactions::class)
|
424
|
|
- ->assertTableActionHidden('editTransaction', $transaction)
|
425
|
|
- ->assertTableActionHidden('editJournalEntry', $transaction);
|
426
|
|
-});
|
427
|
|
-
|
428
|
400
|
it('replicates a transaction with correct journal entries', function () {
|
429
|
401
|
$originalTransaction = Transaction::factory()
|
430
|
402
|
->forDefaultBankAccount()
|