fix(财务台账): 无真实期初不生成零基流水 (#1405)
This commit is contained in:
parent
cda29213a1
commit
0b5a90456d
@ -124,10 +124,7 @@ class FinanceLedgerCalculator
|
||||
->sortBy('date')
|
||||
->values();
|
||||
if ($accountOpenings->isEmpty()) {
|
||||
$accountOpenings = collect([[
|
||||
'date' => $openingDate,
|
||||
'balance' => 0.0,
|
||||
]]);
|
||||
continue;
|
||||
}
|
||||
|
||||
$balance = 0.0;
|
||||
|
||||
@ -214,6 +214,36 @@ class FinanceLedgerCalculatorTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function test_account_without_actual_opening_does_not_create_zero_based_flows(): void
|
||||
{
|
||||
$db = DB::connection('business_mirror');
|
||||
$db->table('fin_accounts')->insert([
|
||||
'company_name' => '公司E',
|
||||
'account_short' => '无期初账户E',
|
||||
'account_type' => '公户',
|
||||
'bank_name' => '工商银行',
|
||||
'current_balance' => 0,
|
||||
'blocked_amount' => 0,
|
||||
'daily_available' => 0,
|
||||
]);
|
||||
$db->table('fin_transactions')->insert([
|
||||
'txn_date' => '2026-10-18',
|
||||
'account_short' => '无期初账户E',
|
||||
'source' => 'manual',
|
||||
'source_value' => null,
|
||||
'income' => 88.88,
|
||||
'expense' => 0,
|
||||
]);
|
||||
|
||||
$result = app(FinanceLedgerCalculator::class)->recalculate();
|
||||
|
||||
$this->assertSame(2, $result['accounts']);
|
||||
$this->assertSame(3, $result['flows']);
|
||||
$this->assertSame(0, $db->table('fin_daily_flows')
|
||||
->where('account_short', '无期初账户E')
|
||||
->count());
|
||||
}
|
||||
|
||||
public function test_account_opening_date_can_precede_the_global_ledger_opening_date(): void
|
||||
{
|
||||
$db = DB::connection('business_mirror');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user