按供应商付款回单的付款账号匹配银行账户,避免同一公司多账户误归属。 Co-authored-by: 92451 <924518135@qq.com> Co-committed-by: 92451 <924518135@qq.com>
88 lines
3.6 KiB
PHP
88 lines
3.6 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\Business;
|
|
|
|
use App\Models\Auth\Permission;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Tests\Feature\FeatureTestCase;
|
|
|
|
class FinanceLedgerPayableMappingBulkTest extends FeatureTestCase
|
|
{
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
$this->user->attachPermission(
|
|
Permission::where('name', 'read-admin-panel')->firstOrFail()
|
|
);
|
|
|
|
$connection = DB::connection('business_mirror');
|
|
$connection->table('fin_accounts')->insert([
|
|
['company_name' => '唯一账户测试公司甲', 'account_no' => '13150000001966704', 'account_short' => '甲工行', 'account_type' => '公户'],
|
|
['company_name' => '唯一公户测试公司乙', 'account_no' => '10000000000000002', 'account_short' => '乙中行', 'account_type' => '公户'],
|
|
['company_name' => '唯一公户测试公司乙', 'account_no' => 'ALIPAY-0002', 'account_short' => '乙支付宝', 'account_type' => '支付宝'],
|
|
['company_name' => '多公户测试公司丙', 'account_no' => '10000000000000004', 'account_short' => '丙中行', 'account_type' => '公户'],
|
|
['company_name' => '多公户测试公司丙', 'account_no' => '10000000000000004', 'account_short' => '丙华夏', 'account_type' => '公户'],
|
|
]);
|
|
$connection->table('fin_account_map')->insert([
|
|
['source' => 'payable', 'source_value' => '1315 0000 0019 6670 4', 'account_short' => null],
|
|
['source' => 'payable', 'source_value' => '10000000000000002', 'account_short' => null],
|
|
['source' => 'payable', 'source_value' => '10000000000000004', 'account_short' => null],
|
|
['source' => 'payable', 'source_value' => '10000000000000009', 'account_short' => null],
|
|
]);
|
|
}
|
|
|
|
private function previewUrl(): string
|
|
{
|
|
return route('business.financial-ledger.mapping.payable.preview', [
|
|
'company_id' => $this->company->id,
|
|
]);
|
|
}
|
|
|
|
private function applyUrl(): string
|
|
{
|
|
return route('business.financial-ledger.mapping.payable.apply', [
|
|
'company_id' => $this->company->id,
|
|
]);
|
|
}
|
|
|
|
public function test_preview_and_apply_payable_mapping_by_payer_account_number(): void
|
|
{
|
|
$this->loginAs()->postJson($this->previewUrl())
|
|
->assertOk()
|
|
->assertJsonPath('total', 4)
|
|
->assertJsonPath('eligible', 2)
|
|
->assertJsonPath('ambiguous', 1)
|
|
->assertJsonPath('missing', 1);
|
|
|
|
$this->loginAs()->postJson($this->applyUrl())
|
|
->assertOk()
|
|
->assertJsonPath('mapped', 2)
|
|
->assertJsonPath('ambiguous', 1)
|
|
->assertJsonPath('missing', 1);
|
|
|
|
$this->assertDatabaseHas('fin_account_map', [
|
|
'source' => 'payable',
|
|
'source_value' => '1315 0000 0019 6670 4',
|
|
'account_short' => '甲工行',
|
|
'updated_by' => 'Test User',
|
|
], 'business_mirror');
|
|
$this->assertDatabaseHas('fin_account_map', [
|
|
'source' => 'payable',
|
|
'source_value' => '10000000000000002',
|
|
'account_short' => '乙中行',
|
|
], 'business_mirror');
|
|
$this->assertDatabaseHas('fin_account_map', [
|
|
'source' => 'payable',
|
|
'source_value' => '10000000000000004',
|
|
'account_short' => null,
|
|
], 'business_mirror');
|
|
$this->assertDatabaseHas('fin_account_map', [
|
|
'source' => 'payable',
|
|
'source_value' => '10000000000000009',
|
|
'account_short' => null,
|
|
], 'business_mirror');
|
|
$this->assertDatabaseCount('fin_account_map_events', 2, 'business_mirror');
|
|
}
|
|
}
|