feat: 增加OA发票及出纳打款抬头 (#1222)

This commit is contained in:
yueyang 2026-11-17 10:47:03 +08:00
parent 7d9f3d7bd1
commit 6cecd87e05
8 changed files with 145 additions and 5 deletions

View File

@ -0,0 +1,50 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
private function connection(): string
{
return (string) config('upstream_mirrors.connection', 'business_mirror');
}
public function up(): void
{
if (app()->environment('testing')
|| (string) config('system_database.mode', 'bootstrap') === 'bootstrap') {
return;
}
$schema = Schema::connection($this->connection());
if (! $schema->hasTable('ding_process_detail_mirror')
|| $schema->hasColumn('ding_process_detail_mirror', 'invoice_title')) {
return;
}
$schema->table('ding_process_detail_mirror', function (Blueprint $table): void {
$table->string('invoice_title', 255)->nullable()->after('purpose');
$table->string('cashier_payment_title', 255)->nullable()->after('invoice_title');
});
}
public function down(): void
{
if (app()->environment('testing')
|| (string) config('system_database.mode', 'bootstrap') === 'bootstrap') {
return;
}
$schema = Schema::connection($this->connection());
if (! $schema->hasTable('ding_process_detail_mirror')
|| ! $schema->hasColumn('ding_process_detail_mirror', 'invoice_title')) {
return;
}
$schema->table('ding_process_detail_mirror', function (Blueprint $table): void {
$table->dropColumn(['invoice_title', 'cashier_payment_title']);
});
}
};

View File

@ -84,6 +84,7 @@ class ProcessDetails extends Controller
fwrite($stream, "\xEF\xBB\xBF");
$headers = DingProcessDetailMirrorImporter::HEADERS;
array_splice($headers, 2, 0, ['发起人部门']);
array_splice($headers, 7, 0, ['发票抬头', '出纳打款抬头']);
fputcsv($stream, [...$headers, '付款状态', '付款差额']);
$number = 0;
@ -97,6 +98,8 @@ class ProcessDetails extends Controller
(string) ($row['status'] ?? ''),
(string) ($row['document_type'] ?? ''),
(string) ($row['purpose'] ?? ''),
(string) ($row['invoice_title'] ?? ''),
(string) ($row['cashier_payment_title'] ?? ''),
(int) ($row['line_no'] ?? 0),
(string) ($row['account_code'] ?? ''),
(string) ($row['account_name'] ?? ''),

View File

@ -1111,6 +1111,8 @@ class DingProcessDetailMirrorSynchronizer
$title,
'',
'',
'',
'',
$this->storeName([], $fields),
$originator,
$documentType,
@ -1274,7 +1276,7 @@ class DingProcessDetailMirrorSynchronizer
: [];
if ($tableName !== '' && ! $this->emptyTableValue($officialTableValue)) {
$officialRows = $this->tableRows($officialTableValue, $workflow, $tableName, $issues);
$rows = $this->mergeOfficialDetailAccountFields($rows, $officialRows);
$rows = $this->mergeOfficialDetailFields($rows, $officialRows);
}
if ($tableName === '' && (bool) ($process['scalar_detail'] ?? false)) {
$rows = [$this->scalarDetailRow($fields)];
@ -1305,6 +1307,8 @@ class DingProcessDetailMirrorSynchronizer
if ($accountName === '') {
$accountName = trim((string) ($process['fallback_account_name'] ?? ''));
}
$invoiceTitle = trim((string) ($row['开票抬头'] ?? $row['发票抬头'] ?? ''));
$cashierPaymentTitle = trim((string) ($row['出纳打款抬头'] ?? ''));
$details[] = $this->detailRecord(
$workflow,
$process,
@ -1315,6 +1319,8 @@ class DingProcessDetailMirrorSynchronizer
$this->purpose($row) ?: (string) ($workflow['title'] ?? ''),
$accountCode,
$accountName,
$invoiceTitle,
$cashierPaymentTitle,
$storeName,
$originator,
$documentType,
@ -1332,13 +1338,13 @@ class DingProcessDetailMirrorSynchronizer
/**
* The replica table can lag behind DingTalk's current table definition.
* Keep replica business values and only fill missing account columns.
* Keep replica business values and only fill missing detail columns.
*
* @param list<array<string,string>> $rows
* @param list<array<string,string>> $officialRows
* @return list<array<string,string>>
*/
private function mergeOfficialDetailAccountFields(array $rows, array $officialRows): array
private function mergeOfficialDetailFields(array $rows, array $officialRows): array
{
$bySequence = [];
foreach ($officialRows as $index => $officialRow) {
@ -1357,7 +1363,15 @@ class DingProcessDetailMirrorSynchronizer
if ($officialRow === null) {
continue;
}
foreach (['科目编码', '科目名称', '店铺', '店铺名称'] as $field) {
foreach ([
'科目编码',
'科目名称',
'店铺',
'店铺名称',
'开票抬头',
'发票抬头',
'出纳打款抬头',
] as $field) {
if (trim((string) ($row[$field] ?? '')) === ''
&& trim((string) ($officialRow[$field] ?? '')) !== '') {
$row[$field] = (string) $officialRow[$field];
@ -2069,6 +2083,8 @@ class DingProcessDetailMirrorSynchronizer
string $purpose,
string $accountCode,
string $accountName,
string $invoiceTitle,
string $cashierPaymentTitle,
string $storeName,
string $originator,
string $documentType,
@ -2110,6 +2126,8 @@ class DingProcessDetailMirrorSynchronizer
'cashier_task_started_at' => $taskState['cashier_task_started_at'] ?? null,
'document_type' => mb_substr($documentType, 0, 100),
'purpose' => $purpose,
'invoice_title' => mb_substr($invoiceTitle, 0, 255),
'cashier_payment_title' => mb_substr($cashierPaymentTitle, 0, 255),
'account_code' => mb_substr($accountCode, 0, 64),
'account_name' => mb_substr($accountName, 0, 255),
'store_name' => mb_substr($storeName, 0, 500),

View File

@ -1429,6 +1429,8 @@
<th>已等待</th>
<th>单据类型</th>
<th>用途/摘要</th>
<th>发票抬头</th>
<th>出纳打款抬头</th>
<th class="center">单据内行号</th>
<th>科目编码</th>
<th>科目名称</th>
@ -1500,6 +1502,8 @@
<td>{{ $waitText($row->current_task_started_at ?? null) }}</td>
<td>{{ $text($row->document_type) }}</td>
<td class="wide" title="{{ $row->purpose }}">{{ $text($row->purpose) }}</td>
<td class="wide" title="{{ $row->invoice_title ?? '' }}">{{ $text($row->invoice_title ?? null) }}</td>
<td class="wide" title="{{ $row->cashier_payment_title ?? '' }}">{{ $text($row->cashier_payment_title ?? null) }}</td>
<td class="center">{{ $row->line_no }}</td>
<td>{{ $text($row->account_code) }}</td>
<td class="wide" title="{{ $row->account_name }}">{{ $text($row->account_name) }}</td>
@ -1514,7 +1518,7 @@
@endif
@empty
<tr>
<td colspan="{{ $pendingPaymentSummaryMode ? 6 : ($approvalSummaryMode ? 7 : 21) }}" class="process-details-empty">
<td colspan="{{ $pendingPaymentSummaryMode ? 6 : ($approvalSummaryMode ? 7 : 23) }}" class="process-details-empty">
当前筛选条件没有OA流程数据。可以调整月份、单据类型、状态或关键词后重试。
</td>
</tr>

View File

@ -36,6 +36,8 @@ class ProcessDetailsPageTest extends FeatureTestCase
->format('Y-m-d H:i:s'),
'document_type' => '公摊日常报销',
'purpose' => '办公用品采购',
'invoice_title' => '江苏简尚品牌管理有限公司',
'cashier_payment_title' => '常州欧伯娜家居有限公司',
'account_code' => '5602.04',
'account_name' => '管理费用_办公费',
'amount' => 100.00,
@ -124,6 +126,10 @@ class ProcessDetailsPageTest extends FeatureTestCase
->assertSee('<option value="已付款"', false)
->assertSee('下拉选择后自动查询', false)
->assertSee('当前审批人')
->assertSee('发票抬头')
->assertSee('出纳打款抬头')
->assertSee('江苏简尚品牌管理有限公司')
->assertSee('常州欧伯娜家居有限公司')
->assertSee('进入时间')
->assertSee('已等待')
->assertSee('审批单数')
@ -614,6 +620,8 @@ class ProcessDetailsPageTest extends FeatureTestCase
'payment_difference' => 0.20,
'document_type' => '公摊日常报销',
'purpose' => '办公用品采购',
'invoice_title' => '江苏简尚品牌管理有限公司',
'cashier_payment_title' => '常州欧伯娜家居有限公司',
'line_no' => 1,
'account_code' => '5602.04',
'account_name' => '管理费用_办公费',
@ -634,11 +642,38 @@ class ProcessDetailsPageTest extends FeatureTestCase
$response->assertOk();
$content = $response->streamedContent();
$header = str_getcsv(ltrim((string) strtok($content, "\r\n"), "\xEF\xBB\xBF"));
$this->assertSame([
'序号',
'审批编号',
'发起人部门',
'发起人',
'状态',
'单据类型',
'用途/摘要',
'发票抬头',
'出纳打款抬头',
'单据内行号',
'科目编码',
'科目名称',
'金额(元)',
'银行科目编码',
'银行科目名称',
'银行付款金额',
'付款方式',
'打款时间',
'付款状态',
'付款差额',
], $header);
$this->assertStringContainsString('审批编号', $content);
$this->assertStringContainsString('发起人部门', $content);
$this->assertStringContainsString('202601011200000000001', $content);
$this->assertStringContainsString('销售中心', $content);
$this->assertStringContainsString('张三', $content);
$this->assertStringContainsString('发票抬头', $content);
$this->assertStringContainsString('出纳打款抬头', $content);
$this->assertStringContainsString('江苏简尚品牌管理有限公司', $content);
$this->assertStringContainsString('常州欧伯娜家居有限公司', $content);
$this->assertStringContainsString('管理费用_办公费', $content);
$this->assertStringContainsString('付款状态', $content);
$this->assertStringContainsString('已付款', $content);

View File

@ -49,6 +49,8 @@ class DingProcessDetailMirrorRepositoryTest extends TestCase
$paymentStates = collect($result['data'])->pluck('payment_state')->unique()->all();
$this->assertContains('已付款', $paymentStates);
$this->assertContains('待付款', $paymentStates);
$this->assertContains('江苏简尚品牌管理有限公司', collect($result['data'])->pluck('invoice_title')->all());
$this->assertContains('常州欧伯娜家居有限公司', collect($result['data'])->pluck('cashier_payment_title')->all());
$options = $this->repository->filterOptions();
$this->assertArrayNotHasKey('months', $options);
@ -657,6 +659,8 @@ class DingProcessDetailMirrorRepositoryTest extends TestCase
: '2026-02-03 09:00:00',
'document_type' => $documentType,
'purpose' => $purpose,
'invoice_title' => '江苏简尚品牌管理有限公司',
'cashier_payment_title' => '常州欧伯娜家居有限公司',
'account_code' => '5602.04',
'account_name' => '管理费用_办公费',
'amount' => $amount,
@ -719,6 +723,8 @@ class DingProcessDetailMirrorRepositoryTest extends TestCase
$table->dateTime('cashier_task_started_at')->nullable();
$table->string('document_type', 100)->nullable()->index();
$table->text('purpose')->nullable();
$table->string('invoice_title', 255)->nullable();
$table->string('cashier_payment_title', 255)->nullable();
$table->string('account_code', 64)->nullable();
$table->string('account_name', 255)->nullable();
$table->decimal('amount', 18, 2)->nullable();

View File

@ -115,6 +115,12 @@ class DingProcessDetailMirrorSynchronizerTest extends TestCase
->table('ding_process_detail_mirror')->value('approval_finished_at'));
$this->assertSame('天猫-测试店铺', DB::connection('business_mirror')
->table('ding_process_detail_mirror')->value('store_name'));
$firstDetail = DB::connection('business_mirror')
->table('ding_process_detail_mirror')
->orderBy('line_no')
->first();
$this->assertSame('江苏简尚品牌管理有限公司', $firstDetail->invoice_title);
$this->assertSame('常州欧伯娜家居有限公司', $firstDetail->cashier_payment_title);
$summary = app(DingProcessDetailMirrorRepository::class)
->paginate(['status' => '已完成'], 1, 50)['summary'];
@ -374,6 +380,8 @@ class DingProcessDetailMirrorSynchronizerTest extends TestCase
['label' => '收款金额', 'value' => '100.00'],
['label' => '科目编码', 'value' => '1221.01'],
['label' => '科目名称', 'value' => '其他应收款_运营中心-种菜刷单'],
['label' => '开票抬头', 'value' => '江苏简尚品牌管理有限公司'],
['label' => '出纳打款抬头', 'value' => '常州欧伯娜家居有限公司'],
],
],
[
@ -382,6 +390,8 @@ class DingProcessDetailMirrorSynchronizerTest extends TestCase
['label' => '收款金额', 'value' => '50.00'],
['label' => '科目编码', 'value' => '1221.01'],
['label' => '科目名称', 'value' => '其他应收款_运营中心-种菜刷单'],
['label' => '开票抬头', 'value' => '江苏简尚品牌管理有限公司'],
['label' => '出纳打款抬头', 'value' => '常州欧伯娜家居有限公司'],
],
],
], JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR),
@ -400,6 +410,14 @@ class DingProcessDetailMirrorSynchronizerTest extends TestCase
['其他应收款_运营中心-种菜刷单', '其他应收款_运营中心-种菜刷单'],
$rows->pluck('account_name')->all(),
);
$this->assertSame(
['江苏简尚品牌管理有限公司', '江苏简尚品牌管理有限公司'],
$rows->pluck('invoice_title')->all(),
);
$this->assertSame(
['常州欧伯娜家居有限公司', '常州欧伯娜家居有限公司'],
$rows->pluck('cashier_payment_title')->all(),
);
$this->assertContains('process-account-columns', $this->approvalClient->calls);
}
@ -1396,6 +1414,8 @@ class DingProcessDetailMirrorSynchronizerTest extends TestCase
['label' => '代发订单金额', 'value' => (string) $amount],
['label' => '科目编码', 'value' => '1405.06'],
['label' => '科目名称', 'value' => '库存商品_线上代发'],
['label' => '开票抬头', 'value' => '江苏简尚品牌管理有限公司'],
['label' => '出纳打款抬头', 'value' => '常州欧伯娜家居有限公司'],
['label' => '店铺', 'value' => '["天猫-测试店铺"]'],
],
], $amounts);
@ -1481,6 +1501,8 @@ class DingProcessDetailMirrorSynchronizerTest extends TestCase
$table->dateTime('cashier_task_started_at')->nullable();
$table->string('document_type', 100)->nullable();
$table->text('purpose')->nullable();
$table->string('invoice_title', 255)->nullable();
$table->string('cashier_payment_title', 255)->nullable();
$table->string('account_code', 64)->nullable();
$table->string('account_name', 255)->nullable();
$table->string('store_name', 500)->nullable();

View File

@ -57,6 +57,8 @@ class ProcessDetailsPageDataTest extends TestCase
$this->assertStringContainsString('应付金额与实际付款金额不要求相等', $content);
$this->assertStringContainsString('不涉及付款的明细仍可查看但不计入应付金额', $content);
$this->assertStringContainsString('<th>用途</th>', $content);
$this->assertStringContainsString('<th>发票抬头</th>', $content);
$this->assertStringContainsString('<th>出纳打款抬头</th>', $content);
$this->assertStringContainsString('<th class="num">应付金额</th>', $content);
$this->assertStringContainsString('<th class="num">实际付款</th>', $content);
$this->assertStringContainsString('<th>进入时间</th>', $content);