diff --git a/modules/EcommerceFinance/Services/AccountMappingStore.php b/modules/EcommerceFinance/Services/AccountMappingStore.php index d1a7f0bb..9e8e505f 100644 --- a/modules/EcommerceFinance/Services/AccountMappingStore.php +++ b/modules/EcommerceFinance/Services/AccountMappingStore.php @@ -42,12 +42,16 @@ class AccountMappingStore /** 大类 → 预期方向基准(用于校验「基准与大类是否一致」) */ public const CATEGORY_BASIS = [ '费用' => self::BASIS_OUT, - '保证金' => self::BASIS_OUT, + '售后费用' => self::BASIS_OUT, + '平台服务费' => self::BASIS_OUT, + '平台佣金' => self::BASIS_OUT, '推广' => self::BASIS_OUT, + '保证金' => self::BASIS_OUT, '暂挂' => self::BASIS_OUT, '营业外支出' => self::BASIS_OUT, '提现' => self::BASIS_OUT, '收入' => self::BASIS_IN, + '往来' => self::BASIS_IN, '转账' => self::BASIS_IN, ]; diff --git a/modules/EcommerceFinance/Services/AccountMappingWorkbookImporter.php b/modules/EcommerceFinance/Services/AccountMappingWorkbookImporter.php index e44562d5..05193aa6 100644 --- a/modules/EcommerceFinance/Services/AccountMappingWorkbookImporter.php +++ b/modules/EcommerceFinance/Services/AccountMappingWorkbookImporter.php @@ -33,6 +33,9 @@ class AccountMappingWorkbookImporter ]; private const INVOICE_MAP = [ + '0' => '不开票', + '0.00' => '不开票', + '0%' => '不开票', '0.06' => '0.06', '6%' => '0.06', '06' => '0.06', diff --git a/resources/views/business/pages/financial-rules/account-mapping.blade.php b/resources/views/business/pages/financial-rules/account-mapping.blade.php index d312904f..caface90 100644 --- a/resources/views/business/pages/financial-rules/account-mapping.blade.php +++ b/resources/views/business/pages/financial-rules/account-mapping.blade.php @@ -374,8 +374,10 @@ // 大类 → 预期方向基准:改大类时顺手把基准带过去,避免两者打架 var CATEGORY_BASIS = { - '费用': '支出基准', '保证金': '支出基准', '推广': '支出基准', '暂挂': '支出基准', - '营业外支出': '支出基准', '提现': '支出基准', '收入': '收入基准', '转账': '收入基准' + '费用': '支出基准', '售后费用': '支出基准', '平台服务费': '支出基准', '平台佣金': '支出基准', + '推广': '支出基准', '保证金': '支出基准', '暂挂': '支出基准', + '营业外支出': '支出基准', '提现': '支出基准', + '收入': '收入基准', '往来': '收入基准', '转账': '收入基准' }; var body = document.getElementById('amBody'); diff --git a/tests/Feature/Business/AccountMappingPageTest.php b/tests/Feature/Business/AccountMappingPageTest.php index 460f6da2..2703967f 100644 --- a/tests/Feature/Business/AccountMappingPageTest.php +++ b/tests/Feature/Business/AccountMappingPageTest.php @@ -208,4 +208,40 @@ class AccountMappingPageTest extends FeatureTestCase ->assertStatus(422) ->assertJsonPath('errors.import.0', '只支持 xlsx、xls、csv 三种格式,当前是「txt」。'); } + + /** + * 抖音账单带来的 5 个大类并入固定清单(往来=收入基准),票据「0」按不开票入库。 + */ + public function test_douyin_categories_are_fixed_options_and_zero_invoice_means_no_invoice(): void + { + $this->grantAdminPermission(); + + $this->assertSame([ + '售后费用' => '支出基准', + '平台服务费' => '支出基准', + '平台佣金' => '支出基准', + '往来' => '收入基准', + ], array_intersect_key(AccountMappingStore::CATEGORY_BASIS, array_flip([ + '售后费用', '平台服务费', '平台佣金', '往来', + ]))); + + $categories = $this->loginAs()->getJson($this->rulesUrl())->assertOk()->json('options.categories'); + foreach (['售后费用', '平台服务费', '平台佣金', '往来'] as $category) { + $this->assertContains($category, $categories); + } + + $csv = "平台,账单项目,财务备注,票据,大类,借方科目,贷方科目,方向基准\n" + . "自测平台,自测项目丙,备注丙,0,售后费用,销售费用,其他货币资金,支出基准\n"; + + $this->loginAs()->post($this->actionUrl('import'), [ + 'import' => UploadedFile::fake()->createWithContent('rules.csv', $csv), + ], ['Accept' => 'application/json']) + ->assertOk() + ->assertJsonPath('result.created', 1); + + $rule = collect(app(AccountMappingStore::class)->all())->firstWhere('item', '自测项目丙'); + $this->assertNotNull($rule); + $this->assertSame('不开票', $rule['invoice']); + $this->assertSame('支出基准', $rule['basis']); + } }