科目映射表:新增费用备注列并回填费用备注数据

This commit is contained in:
qiuxiang 2026-10-19 14:24:10 +08:00
parent 664fc05faf
commit 9f4f4f0cbb
5 changed files with 44 additions and 13 deletions

View File

@ -42,6 +42,7 @@ class AccountMappingActions extends Controller
'memo' => '财务备注',
'invoice' => '票据口径',
'category' => '大类',
'feeMemo' => '费用备注',
'dAcct' => '借方科目',
'dSub' => '借方二级',
'cAcct' => '贷方科目',
@ -353,8 +354,8 @@ class AccountMappingActions extends Controller
public function template(): StreamedResponse
{
$samples = [
['得物', '平台服务费', '平台服务费', '0.06', '费用', '销售费用', '平台佣金', '其他货币资金', '', '支出基准'],
['淘宝', '交易收入', '订单', '-', '收入', '其他货币资金', '', '主营业务收入', '', '收入基准'],
['得物', '平台服务费', '平台服务费', '-', '0.06', '费用', '平台服务费', '销售费用', '平台服务费', '其他货币资金', '', '支出基准'],
['淘宝', '交易收入', '订单', '-', '-', '收入', '收入', '其他货币资金', '', '主营业务收入', '', '收入基准'],
];
return response()->streamDownload(function () use ($samples): void {

View File

@ -0,0 +1,22 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('ec_account_mapping_rules', function (Blueprint $table): void {
$table->string('fee_memo', 191)->default('')->after('category');
});
}
public function down(): void
{
Schema::table('ec_account_mapping_rules', function (Blueprint $table): void {
$table->dropColumn('fee_memo');
});
}
};

View File

@ -34,7 +34,7 @@ class AccountMappingStore
public const EVENTS_TABLE = 'ec_account_mapping_events';
/** 可维护字段(顺序即导出/模板列顺序) */
public const FIELDS = ['platform', 'item', 'memo', 'goods', 'invoice', 'category', 'dAcct', 'dSub', 'cAcct', 'cSub', 'basis'];
public const FIELDS = ['platform', 'item', 'memo', 'goods', 'invoice', 'category', 'feeMemo', 'dAcct', 'dSub', 'cAcct', 'cSub', 'basis'];
public const LABELS = [
'platform' => '平台',
@ -43,6 +43,7 @@ class AccountMappingStore
'goods' => '商品名称关键词',
'invoice' => '票据口径',
'category' => '财务类型',
'feeMemo' => '费用备注',
'dAcct' => '借方科目',
'dSub' => '借方二级',
'cAcct' => '贷方科目',
@ -626,6 +627,7 @@ class AccountMappingStore
'goods' => (string) $row->goods,
'invoice' => (string) $row->invoice,
'category' => (string) $row->category,
'feeMemo' => (string) ($row->fee_memo ?? ''),
'dAcct' => (string) $row->d_acct,
'dSub' => (string) $row->d_sub,
'cAcct' => (string) $row->c_acct,
@ -648,6 +650,7 @@ class AccountMappingStore
'goods' => $rule['goods'],
'invoice' => $rule['invoice'],
'category' => $rule['category'],
'fee_memo' => $rule['feeMemo'],
'd_acct' => $rule['dAcct'],
'd_sub' => $rule['dSub'],
'c_acct' => $rule['cAcct'],

View File

@ -26,6 +26,7 @@ class AccountMappingWorkbookImporter
'goods' => ['商品名称关键词', '商品名称', '商品描述', '货品名称'],
'invoice' => ['票据口径', '票据', '票据类型', '发票'],
'category' => ['财务类型', '大类', '业务性质', '科目大类', '分类'],
'feeMemo' => ['费用备注', '费用说明', '费用备注说明'],
'basis' => ['方向基准', '基准'],
'dAcct' => ['借方科目', '借/贷(借)', '借/贷(借)', '借方'],
'dSub' => ['借方二级'],

View File

@ -103,10 +103,10 @@
/* 表格必须锁列宽(table-layout:fixed)。默认的自动列宽会按内容互相挤压,
「借方/贷方科目」两列会被挤到文字被截断;锁死后按上面 th 的宽度分配,
窗口不够宽时由外层 .upstream-data-table-scroll 横向滚动。
89rem = 各列宽度之和,改列宽时要一起改。 */
115rem = 各列宽度之和,改列宽时要一起改。 */
/* min-width 必须不小于各列宽度之和,否则窄屏下浏览器会按比例压缩各列,
固定的 4.5rem 平台列又会被压到装不下「唯品会JX」这类值。 */
.am-table { table-layout: fixed; min-width: 106rem; }
.am-table { table-layout: fixed; min-width: 115rem; }
/* 只读单元格超长就省略号(编辑态那格要放开,否则下拉会被裁) */
.am-table > tbody > tr.am-item:not(.is-editing) > td { overflow: hidden; text-overflow: ellipsis; }
@ -496,6 +496,7 @@
<th style="width:11rem;">商品名称关键词</th>
<th style="width:5rem;">票据</th>
<th style="width:8rem;">财务类型</th>
<th style="width:9rem;">费用备注</th>
<th style="width:12rem;">借方科目</th>
<th style="width:12rem;">贷方科目</th>
<th style="width:6rem;">方向基准</th>
@ -805,9 +806,9 @@
+ '<span>' + esc(i.message) + '</span></div>';
}).join('') + '</div>';
}
return '<tr class="am-detail"><td colspan="11"><div class="am-detail__box">'
return '<tr class="am-detail"><td colspan="13"><div class="am-detail__box">'
+ '<div class="am-detail__head">' + esc(r.platform) + ' · ' + esc(r.item)
+ ' (基准:' + esc(r.basis) + ',记录 ' + r.id + ')</div>'
+ ' (费用备注:' + esc(r.feeMemo || '—') + ',基准:' + esc(r.basis) + ',记录 ' + r.id + ')</div>'
+ '<div class="am-flow">'
+ line('out', '账单支出', out)
+ line('in', '账单收入', inn)
@ -859,7 +860,7 @@
if (fOnly.value === 'issue' && !n.error && !n.warning && !n.tip) { return false; }
}
if (keyword) {
var hay = [r.platform, r.item, r.memo, r.goods, r.dAcct, r.dSub, r.cAcct, r.cSub, r.category, r.basis]
var hay = [r.platform, r.item, r.memo, r.goods, r.dAcct, r.dSub, r.cAcct, r.cSub, r.category, r.feeMemo, r.basis]
.join(' ').toLowerCase();
if (hay.indexOf(keyword) < 0) { return false; }
}
@ -878,6 +879,7 @@
+ '<td class="am-edit-cell"><input data-f="goods" value="' + esc(draft.goods) + '" placeholder="不限就填 -"></td>'
+ '<td class="am-edit-cell"><select data-f="invoice">' + optionsHtml(OPTIONS.invoices || [], draft.invoice) + '</select></td>'
+ '<td class="am-edit-cell"><select data-f="category">' + optionsHtml(OPTIONS.categories || [], draft.category) + '</select></td>'
+ '<td class="am-edit-cell"><input data-f="feeMemo" value="' + esc(draft.feeMemo) + '" placeholder="费用备注"></td>'
+ '<td class="am-edit-cell">' + acctEditor('dAcct', 'dSub') + '</td>'
+ '<td class="am-edit-cell">' + acctEditor('cAcct', 'cSub') + '</td>'
+ '<td class="am-edit-cell"><select data-f="basis">' + optionsHtml(OPTIONS.basis || [], draft.basis) + '</select></td>'
@ -895,6 +897,7 @@
+ '<td><span title="' + esc(r.goods) + '">' + esc(r.goods || '-') + '</span></td>'
+ '<td>' + esc(r.invoice || '—') + '</td>'
+ '<td><span title="' + esc(r.category) + '">' + esc(r.category) + '</span></td>'
+ '<td><span title="' + esc(r.feeMemo) + '">' + esc(r.feeMemo || '-') + '</span></td>'
+ '<td><span title="' + esc(acctText(r.dAcct, r.dSub)) + '">' + acct(r.dAcct, r.dSub) + '</span></td>'
+ '<td><span title="' + esc(acctText(r.cAcct, r.cSub)) + '">' + acct(r.cAcct, r.cSub) + '</span></td>'
+ '<td>' + basisTag(r.basis) + '</td>'
@ -1130,7 +1133,7 @@
function collectDraft() {
var values = {};
['platform', 'item', 'memo', 'goods', 'invoice', 'category', 'dAcct', 'dSub', 'cAcct', 'cSub', 'basis'].forEach(function (f) {
['platform', 'item', 'memo', 'goods', 'invoice', 'category', 'feeMemo', 'dAcct', 'dSub', 'cAcct', 'cSub', 'basis'].forEach(function (f) {
values[f] = draft[f] == null ? '' : draft[f];
});
return values;
@ -1142,7 +1145,7 @@
if (!r) { return; }
draft = {
platform: r.platform, item: r.item, memo: r.memo, goods: r.goods, invoice: r.invoice,
category: r.category, dAcct: r.dAcct, dSub: r.dSub, cAcct: r.cAcct, cSub: r.cSub, basis: r.basis
category: r.category, feeMemo: r.feeMemo, dAcct: r.dAcct, dSub: r.dSub, cAcct: r.cAcct, cSub: r.cSub, basis: r.basis
};
editingId = id;
collapseDetail();
@ -1173,7 +1176,7 @@
loadCoa().then(function () {
draft = {
platform: '', item: '', memo: '', goods: '', invoice: '-', category: '费用',
dAcct: '', dSub: '', cAcct: '', cSub: '', basis: '支出基准'
feeMemo: '', dAcct: '', dSub: '', cAcct: '', cSub: '', basis: '支出基准'
};
editingId = 'new';
collapseDetail();
@ -1192,6 +1195,7 @@
+ '<td class="am-edit-cell"><input data-f="goods" value="' + esc(draft.goods) + '" placeholder="不限就填 -"></td>'
+ '<td class="am-edit-cell"><select data-f="invoice">' + optionsHtml(OPTIONS.invoices || [], draft.invoice) + '</select></td>'
+ '<td class="am-edit-cell"><select data-f="category">' + optionsHtml(OPTIONS.categories || [], draft.category) + '</select></td>'
+ '<td class="am-edit-cell"><input data-f="feeMemo" value="' + esc(draft.feeMemo) + '" placeholder="费用备注"></td>'
+ '<td class="am-edit-cell">' + acctEditor('dAcct', 'dSub') + '</td>'
+ '<td class="am-edit-cell">' + acctEditor('cAcct', 'cSub') + '</td>'
+ '<td class="am-edit-cell"><select data-f="basis">' + optionsHtml(OPTIONS.basis || [], draft.basis) + '</select></td>'
@ -1240,7 +1244,7 @@
var rows = (data.sample || []).map(function (r) {
return '<tr><td>' + esc(r.platform) + '</td><td>' + esc(r.item) + '</td><td>' + esc(r.memo) + '</td>'
+ '<td>' + esc(r.goods) + '</td>'
+ '<td>' + esc(r.category) + '</td><td>' + acct(r.dAcct, r.dSub) + '</td><td>' + acct(r.cAcct, r.cSub) + '</td>'
+ '<td>' + esc(r.category) + '</td><td>' + esc(r.feeMemo) + '</td><td>' + acct(r.dAcct, r.dSub) + '</td><td>' + acct(r.cAcct, r.cSub) + '</td>'
+ '<td>' + esc(r.basis) + '</td></tr>';
}).join('');
var dupList = (data.duplicate_keys || []).length
@ -1255,7 +1259,7 @@
+ '<label class="am-check"><input type="checkbox" id="amOverwrite"> 重复的那些用文件里的内容覆盖现有规则(不勾选则跳过)</label>'
+ dupList
+ '<div style="margin-top:0.75rem;">前 ' + (data.sample || []).length + ' 行预览:</div>'
+ '<table class="am-preview-table"><thead><tr><th>平台</th><th>账单项目</th><th>财务备注</th><th>商品名称</th><th>财务类型</th><th>借方</th><th>贷方</th><th>基准</th></tr></thead><tbody>' + rows + '</tbody></table>';
+ '<table class="am-preview-table"><thead><tr><th>平台</th><th>账单项目</th><th>财务备注</th><th>商品名称</th><th>财务类型</th><th>费用备注</th><th>借方</th><th>贷方</th><th>基准</th></tr></thead><tbody>' + rows + '</tbody></table>';
var foot = '<button type="button" class="am-btn" id="amImportCancel">取消</button>'
+ '<button type="button" class="am-btn am-btn--primary" id="amImportConfirm">确认导入</button>';