user->attachPermission(
Permission::where('name', 'read-admin-panel')->firstOrFail()
);
config(['upstream_mirrors.connection' => 'sqlite']);
Schema::dropIfExists('piaoju_seller_quota_snapshots');
Schema::create('piaoju_seller_quota_snapshots', function (Blueprint $table): void {
$table->bigIncrements('id');
$table->string('seller_key', 64)->unique();
$table->string('seller_name', 191);
$table->string('tax_number', 64)->nullable();
$table->boolean('seller_status')->nullable();
$table->string('auth_status', 32)->nullable();
$table->string('auth_status_desc', 64)->nullable();
$table->decimal('invoice_limit', 18, 2)->nullable();
$table->dateTime('invoice_limit_updated_at')->nullable();
$table->dateTime('source_fetched_at');
$table->dateTime('synced_at');
$table->timestamps();
});
$this->createInvoiceBasic('甲公司', '甲店铺组', 10000, 8500, '2026-11');
$this->createInvoiceBasic('乙公司', '乙店铺', 2000, 2500, '2026-11');
$this->createInvoiceBasic('丙公司', '丙店铺', 5000, 1000, '2026-11');
$this->createInvoiceBasic('零额度公司', '零额度店铺', 0, 0, '2026-11');
$this->createInvoiceBasic('历史公司', '历史店铺', 100, 100, '2026-10');
$this->createPiaojuSnapshot('pi-1', '甲公司', 15000, '2026-11-18 13:30:07');
$this->createPiaojuSnapshot('pi-2', '乙公司', -100, '2026-11-18 13:51:43');
$this->createPiaojuSnapshot('pi-3', '丙公司', 4000, '2026-11-18 13:29:10');
}
public function test_invoice_quota_is_listed_after_invoice_basic_information(): void
{
$pages = collect(config('business_navigation'))
->firstWhere('slug', 'invoice-management')['pages'];
$this->assertSame(
['automatic-invoicing', 'basic-information', 'invoice-quota', 'invoice-reports', 'store-backend-invoicing'],
array_column($pages, 'slug')
);
}
public function test_invoice_quota_defaults_to_latest_period_and_shows_ticket_union_summary(): void
{
$this->loginAs()
->get($this->pageUrl())
->assertOk()
->assertSeeText('发票额度')
->assertSeeText('当前开票额度')
->assertSeeText('17,000.00')
->assertSeeText('12,000.00')
->assertSeeText('18,900.00')
->assertSeeText('甲公司')
->assertSeeText('15,000.00')
->assertSeeText('8,500.00')
->assertDontSeeText('1,500.00')
->assertSeeText('乙公司')
->assertSeeText('-100.00')
->assertSeeText('额度不足')
->assertSeeText('未匹配')
->assertSeeText('不可查看 0 · 额度不足 1')
->assertSeeText('2026-11-18 13:30')
->assertDontSeeText('历史公司')
->assertSee('