diff --git a/app/Http/Controllers/Business/Pages.php b/app/Http/Controllers/Business/Pages.php index 088c7f4c..629ac9ee 100644 --- a/app/Http/Controllers/Business/Pages.php +++ b/app/Http/Controllers/Business/Pages.php @@ -4708,6 +4708,7 @@ class Pages extends Controller 'product-costs' => $this->contentForProductCosts(), 'financial-analysis' => $this->contentForFinancialAnalysis(), 'oa-process' => $this->contentForProcessDetails(), + 'management-expenses' => $this->contentForManagementExpenses(), 'labor-expenses' => $this->contentForLaborExpenses(), 'courier-surcharge' => $this->contentForCourierSurcharge($tab), 'courier-surcharge-settlement' => $this->contentForCourierSurchargeSettlementPage(), @@ -4751,6 +4752,12 @@ class Pages extends Controller return $data; } + protected function contentForManagementExpenses(): array + { + return app(\Modules\EcommerceFinance\View\ManagementExpensesPageData::class) + ->page(request()); + } + protected function contentForLaborExpenses(): array { $saved = app(LaborExpenseDataStore::class)->load(); diff --git a/database/migrations/2026_10_30_200000_create_oa_process_account_mapping_table.php b/database/migrations/2026_10_30_200000_create_oa_process_account_mapping_table.php new file mode 100644 index 00000000..fac438db --- /dev/null +++ b/database/migrations/2026_10_30_200000_create_oa_process_account_mapping_table.php @@ -0,0 +1,95 @@ +environment('testing') + || (string) config('system_database.mode', 'bootstrap') === 'bootstrap') { + return; + } + + $schema = Schema::connection($this->connection()); + if (! $schema->hasTable('oa_process_account_mapping')) { + $schema->create('oa_process_account_mapping', function (Blueprint $table): void { + $table->string('account_code', 64)->primary(); + $table->string('account_name', 255); + $table->string('expense_category', 100)->index(); + $table->string('second_level', 100)->nullable()->index(); + $table->string('third_level', 100)->nullable()->index(); + $table->boolean('in_fee_ratio')->default(false)->index(); + $table->string('allocation', 100)->nullable(); + $table->timestamps(); + }); + } + + if ($schema->hasTable('ding_process_detail_mirror') + && ! $schema->hasIndex('ding_process_detail_mirror', 'ding_process_detail_account_code_index')) { + $schema->table('ding_process_detail_mirror', function (Blueprint $table): void { + $table->index('account_code', 'ding_process_detail_account_code_index'); + }); + } + + $mapping = json_decode( + (string) file_get_contents(base_path('resources/data/oa_process_account_mapping.json')), + true, + 512, + JSON_THROW_ON_ERROR, + ); + $connection = Schema::connection($this->connection()); + $database = $connection->getConnection(); + $now = now(); + foreach (array_chunk($mapping, 100) as $chunk) { + $database->table('oa_process_account_mapping')->upsert( + array_map(static fn (array $row): array => [ + 'account_code' => (string) $row['account_code'], + 'account_name' => (string) $row['account_name'], + 'expense_category' => (string) $row['expense_category'], + 'second_level' => $row['second_level'] + ?? ((string) $row['expense_category'] . '(未细分)'), + 'third_level' => $row['third_level'] ?? '未细分', + 'in_fee_ratio' => (bool) $row['in_fee_ratio'], + 'allocation' => $row['allocation'] ?? null, + 'created_at' => $now, + 'updated_at' => $now, + ], $chunk), + ['account_code'], + [ + 'account_name', + 'expense_category', + 'second_level', + 'third_level', + 'in_fee_ratio', + 'allocation', + 'updated_at', + ], + ); + } + } + + 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->hasIndex('ding_process_detail_mirror', 'ding_process_detail_account_code_index')) { + $schema->table('ding_process_detail_mirror', function (Blueprint $table): void { + $table->dropIndex('ding_process_detail_account_code_index'); + }); + } + $schema->dropIfExists('oa_process_account_mapping'); + } +}; diff --git a/docs/上游业务镜像清单.md b/docs/上游业务镜像清单.md index a6005fef..308d713b 100644 --- a/docs/上游业务镜像清单.md +++ b/docs/上游业务镜像清单.md @@ -34,6 +34,7 @@ | 本次接入 | 普通商品资料的工作平台采购价格接入 `jiansun.dbo.pm_priceAdjustment`(镜像 `js_pm_price_adjustment`):按 `skuCode` 关联 `jst_sku.sku_id`,取 `effectTime` 不晚于当前时间的最新 `purchasePrice`,并在页面和导出中标记“工作平台价格”;源表没有可靠更新时间,按 `Id` 稳定键追加,首次全量完成前只显示普通商品自身采购价。 | | 待有效凭据后首次同步 | 普通商品当前成本价、商品类型和更新时间继续读取 `operations_replica.rpt.jst_sku`;`rpt.fys_skuCostPriceUpdate` 是一 SKU 一行的旧快照,不能充当变价历史。完整成本价变更仍读取聚水潭经典开放平台“商品操作日志查询”接口 `worklog.query`,只镜像操作内容含“采购价”的记录到 `jushuitan_cost_price_history_rows`;经典接口必须在服务器私有配置中使用同一应用的 `JUSHUITAN_PARTNER_ID / JUSHUITAN_PARTNER_KEY / JUSHUITAN_TOKEN`,不得把新开放平台的 App Key / App Secret / Access Token 混用。页面在首次同步完成前明确显示待同步或失败,不把 0 条解释为真实无历史。 | | 本次接入 | 流程明细读取 `operations_replica/rpt.ding_Workflow + rpt.ding_WorkflowScheme` 的结构化审批主表、费用明细和付款明细,写入 `ding_process_detail_mirror` 与 `ding_process_payment_mirror`;主表的 `originatorDeptName` 作为发起人部门单独保留。禁止先把明细表和付款表铺平成 CSV 后逐行求和;付款明细必须按“对应序号”关联到代表明细行,但合计始终读取独立付款事实。每个纳入范围的源审批至少保留一条页面记录,没有费用金额的审批以空金额显示,不静默隐藏。首次全量先运行 `business-mirror:sync-ding-process-details --full --dry-run` 校验,再使用 `business-mirror:sync-ding-process-details --full` 发布;日常通过 `updateAt/createAt` 48 小时重叠增量同步。当前纳入日常报销、应付、线上代发、种菜、快递面单、固定资产、日常物品、样品、一次性采买、板材、工资、外贸费用和种菜充值等 14 个财务流程;发现新的明细流程编码时全量同步报错并保留上一版。 | +| 本次接入 | 财务经营报表 › 管理费用使用 `oa_process_account_mapping` 保存“流程科目映射”工作簿中的 191 个科目编码、科目名称、费用大类、二级、三级、是否进费比和是否分摊规则;页面只读取 OA 流程中付款状态为“已付款”的明细,按费用大类和二级汇总进费比/不进费比/未映射金额,点击二级查看三级汇总与 9 列明细模板。 | 流程明细另设独立定时任务,避免与每分钟科目映射消费争用同一上游目录时被静默跳过。正式发布脚本会覆盖安装 `/etc/cron.d/caiwu-ding-process-details`:每 5 分钟尝试运行 `business-mirror:sync-ding-process-details`,使用独立调度锁并在共用上游锁上最多等待 15 分钟;`scripts/install-ding-process-sync-cron.ps1` 仅作为手工修复入口。任务时间和镜像状态统一使用平台固定时区,审批等待时长按实际小时展示。OA 页面每小时最多把一次当前页“审批中”的审批编号写入定向刷新队列,由每分钟检查一次的批处理命令消费;其他时间直接展示最近镜像,已完成流程不进入即时刷新链路,仍由常规增量和每周全量校准处理付款等后续变化。增量同步除跟进审批主表更新时间外,还以 `ding_WorkflowScheme` 的数字 `id` 高水位发现后补表单行,避免付款明细等新组件写入后主审批 `updateAt` 不变而被漏掉;原地改写同一组件仍由每周全量校准兜底。付款状态只按钉钉“出纳打款”节点判断,分为“出纳状态待同步 / 出纳未开始 / 出纳待打款 / 出纳退回 / 出纳已打款 / 流程终止 / 不涉及付款”。金额差异不参与付款状态判断,另以“付款差额 = 费用合计 − 已付款合计”展示。不能因为金额存在少量差异就覆盖出纳节点事实,也不能因为出纳已通过就隐藏金额差异。 diff --git a/modules/EcommerceFinance/Http/Controllers/ManagementExpenses.php b/modules/EcommerceFinance/Http/Controllers/ManagementExpenses.php new file mode 100644 index 00000000..a38a97c5 --- /dev/null +++ b/modules/EcommerceFinance/Http/Controllers/ManagementExpenses.php @@ -0,0 +1,30 @@ +json(['success' => true, ...$pageData->details($request)]) + ->header('Cache-Control', 'no-store'); + } catch (Throwable $exception) { + report($exception); + + return response() + ->json([ + 'success' => false, + 'message' => '管理费用明细暂时无法读取,请稍后重试。', + ], 503) + ->header('Cache-Control', 'no-store'); + } + } +} diff --git a/modules/EcommerceFinance/View/ManagementExpensesPageData.php b/modules/EcommerceFinance/View/ManagementExpensesPageData.php new file mode 100644 index 00000000..2a94db58 --- /dev/null +++ b/modules/EcommerceFinance/View/ManagementExpensesPageData.php @@ -0,0 +1,517 @@ + '进费比', + 'out' => '不进费比', + 'unmapped' => '未映射科目', + ]; + + public const DETAIL_COLUMNS = [ + 'business_id' => '审批编号', + 'originator_department' => '部门', + 'purpose' => '用途', + 'expense_category' => '分类', + 'second_level' => '二级', + 'third_level' => '三级', + 'amount' => '金额', + 'fee_ratio' => '是否进费比', + 'allocation' => '是否分摊', + ]; + + private readonly ConnectionInterface $connection; + + public function __construct(DatabaseManager $database) + { + $this->connection = $database->connection( + (string) config('upstream_mirrors.connection', 'business_mirror'), + ); + } + + /** @return array */ + public function page(Request $request): array + { + $filters = $this->filters($request); + $page = max(1, (int) $request->query('page', 1)); + $perPage = self::perPage($request->query('per_page')); + + try { + $secondLevel = $this->secondLevelSummary($filters); + $thirdLevel = $this->thirdLevelSummary($filters); + $details = $this->detailResult($filters, $page, $perPage); + $options = $this->options(); + + return [ + 'view' => 'business.pages.financial-operations.management-expenses', + 'pageTitle' => '管理费用', + 'rows' => new LengthAwarePaginator( + $details['rows'], + $details['pagination']['total'], + $perPage, + $page, + [ + 'path' => $request->url(), + 'query' => array_filter( + [...$filters, 'per_page' => $perPage], + static fn (mixed $value): bool => $value !== '' && $value !== null, + ), + ], + ), + 'filters' => $filters, + 'summary' => $details['summary'], + 'secondLevelSummary' => $secondLevel, + 'thirdLevelSummary' => $thirdLevel, + 'options' => $options, + 'perPageOptions' => self::PER_PAGE_OPTIONS, + 'detailColumns' => self::DETAIL_COLUMNS, + 'detailsUrl' => route( + 'business.financial-operations.management-expenses.details', + ['company_id' => company_id() ?: 1], + ), + 'error' => null, + ]; + } catch (Throwable $exception) { + report($exception); + + return [ + 'view' => 'business.pages.financial-operations.management-expenses', + 'pageTitle' => '管理费用', + 'rows' => new LengthAwarePaginator([], 0, $perPage, $page, [ + 'path' => $request->url(), + 'query' => $request->query(), + ]), + 'filters' => $filters, + 'summary' => $this->emptySummary(), + 'secondLevelSummary' => [], + 'thirdLevelSummary' => [], + 'options' => $this->emptyOptions(), + 'perPageOptions' => self::PER_PAGE_OPTIONS, + 'detailColumns' => self::DETAIL_COLUMNS, + 'detailsUrl' => route( + 'business.financial-operations.management-expenses.details', + ['company_id' => company_id() ?: 1], + ), + 'error' => '管理费用数据暂时无法读取,请稍后重试。', + ]; + } + } + + /** @return array */ + public function details(Request $request): array + { + $filters = $this->filters($request); + $page = max(1, (int) $request->query('page', 1)); + $perPage = self::perPage($request->query('per_page')); + + return $this->detailResult($filters, $page, $perPage); + } + + /** @return array */ + public static function filters(Request $request): array + { + [$paidStart, $paidEnd] = self::dateRange( + $request->query('paid_start'), + $request->query('paid_end'), + ); + $feeRatio = trim((string) $request->query('fee_ratio', '')); + if (! array_key_exists($feeRatio, self::FEE_RATIO_OPTIONS)) { + $feeRatio = ''; + } + + return [ + 'paid_start' => $paidStart, + 'paid_end' => $paidEnd, + 'expense_category' => mb_substr(trim((string) $request->query('expense_category', '')), 0, 100), + 'second_level' => mb_substr(trim((string) $request->query('second_level', '')), 0, 100), + 'third_level' => mb_substr(trim((string) $request->query('third_level', '')), 0, 100), + 'fee_ratio' => $feeRatio, + 'allocation' => mb_substr(trim((string) $request->query('allocation', '')), 0, 100), + 'business_id' => mb_substr(trim((string) $request->query('business_id', '')), 0, 32), + 'originator_department' => mb_substr(trim((string) $request->query('originator_department', '')), 0, 255), + 'originator_name' => mb_substr(trim((string) $request->query('originator_name', '')), 0, 100), + 'keyword' => mb_substr(trim((string) $request->query('keyword', '')), 0, 100), + ]; + } + + /** @return list> */ + private function secondLevelSummary(array $filters): array + { + $category = $this->categoryExpression(); + $second = $this->secondLevelExpression(); + $rows = $this->baseQuery($filters) + ->selectRaw("{$category} AS expense_category, {$second} AS second_level") + ->selectRaw($this->amountSplitExpression()) + ->groupByRaw("{$category}, {$second}") + ->orderByRaw('SUM(COALESCE(d.amount, 0)) DESC') + ->orderByRaw("{$category}, {$second}") + ->get(); + + return $rows->map(function (object $row): array { + $values = (array) $row; + $values['group_key'] = $this->groupKey( + (string) $values['expense_category'], + (string) $values['second_level'], + ); + $values['amount_total'] = round((float) $values['amount_total'], 2); + $values['in_fee_ratio_amount'] = round((float) $values['in_fee_ratio_amount'], 2); + $values['non_fee_ratio_amount'] = round((float) $values['non_fee_ratio_amount'], 2); + $values['unmapped_amount'] = round((float) $values['unmapped_amount'], 2); + $values['row_count'] = (int) $values['row_count']; + $values['approval_count'] = (int) $values['approval_count']; + + return $values; + })->all(); + } + + /** @return list> */ + private function thirdLevelSummary(array $filters): array + { + $category = $this->categoryExpression(); + $second = $this->secondLevelExpression(); + $third = $this->thirdLevelExpression(); + $rows = $this->baseQuery($filters) + ->selectRaw("{$category} AS expense_category, {$second} AS second_level, {$third} AS third_level") + ->selectRaw($this->amountSplitExpression()) + ->groupByRaw("{$category}, {$second}, {$third}") + ->orderByRaw('SUM(COALESCE(d.amount, 0)) DESC') + ->orderByRaw("{$third}") + ->get(); + + return $rows->map(function (object $row): array { + $values = (array) $row; + $values['group_key'] = $this->groupKey( + (string) $values['expense_category'], + (string) $values['second_level'], + ); + $values['amount_total'] = round((float) $values['amount_total'], 2); + $values['in_fee_ratio_amount'] = round((float) $values['in_fee_ratio_amount'], 2); + $values['non_fee_ratio_amount'] = round((float) $values['non_fee_ratio_amount'], 2); + $values['unmapped_amount'] = round((float) $values['unmapped_amount'], 2); + $values['row_count'] = (int) $values['row_count']; + $values['approval_count'] = (int) $values['approval_count']; + + return $values; + })->all(); + } + + /** @return array{rows:list>,pagination:array,summary:array} */ + private function detailResult(array $filters, int $page, int $perPage): array + { + $query = $this->baseQuery($filters); + $total = (clone $query)->count(); + $rows = $query + ->select([ + 'd.business_id', + 'd.originator_department', + 'd.purpose', + 'd.amount', + 'd.line_no', + 'd.process_instance_id', + ]) + ->selectRaw($this->categoryExpression() . ' AS expense_category') + ->selectRaw($this->secondLevelExpression() . ' AS second_level') + ->selectRaw($this->thirdLevelExpression() . ' AS third_level') + ->selectRaw($this->feeRatioExpression() . ' AS fee_ratio') + ->selectRaw($this->allocationExpression() . ' AS allocation') + ->orderByDesc('d.paid_at') + ->orderByDesc('d.business_id') + ->orderBy('d.line_no') + ->forPage($page, $perPage) + ->get() + ->map(static fn (object $row): array => [ + 'business_id' => (string) $row->business_id, + 'originator_department' => (string) ($row->originator_department ?? ''), + 'purpose' => (string) ($row->purpose ?? ''), + 'expense_category' => (string) $row->expense_category, + 'second_level' => (string) $row->second_level, + 'third_level' => (string) $row->third_level, + 'amount' => round((float) ($row->amount ?? 0), 2), + 'fee_ratio' => (string) $row->fee_ratio, + 'allocation' => (string) $row->allocation, + ]) + ->all(); + + return [ + 'rows' => $rows, + 'pagination' => [ + 'current_page' => $page, + 'last_page' => max(1, (int) ceil($total / $perPage)), + 'per_page' => $perPage, + 'total' => $total, + ], + 'summary' => $this->summary($filters), + ]; + } + + /** @return array */ + private function summary(array $filters): array + { + $row = $this->baseQuery($filters) + ->selectRaw($this->amountSplitExpression()) + ->first(); + $values = $row === null ? [] : (array) $row; + + return [ + 'amount_total' => round((float) ($values['amount_total'] ?? 0), 2), + 'in_fee_ratio_amount' => round((float) ($values['in_fee_ratio_amount'] ?? 0), 2), + 'non_fee_ratio_amount' => round((float) ($values['non_fee_ratio_amount'] ?? 0), 2), + 'unmapped_amount' => round((float) ($values['unmapped_amount'] ?? 0), 2), + 'row_count' => (int) ($values['row_count'] ?? 0), + 'approval_count' => (int) ($values['approval_count'] ?? 0), + ]; + } + + private function baseQuery(array $filters): Builder + { + $query = $this->connection->table('ding_process_detail_mirror as d') + ->leftJoin( + 'oa_process_account_mapping as m', + 'm.account_code', + '=', + 'd.account_code', + ) + ->where(function (Builder $paid): void { + $paid->where('d.cashier_status', 'completed') + ->orWhere(function (Builder $completed): void { + $completed->where('d.status', '已完成') + ->whereNotNull('d.payment_source_state') + ->where('d.payment_source_state', '<>', 'not_applicable'); + }); + }); + + if (($filters['paid_start'] ?? '') !== '') { + $query->where('d.paid_at', '>=', $filters['paid_start']); + } + if (($filters['paid_end'] ?? '') !== '') { + $query->where( + 'd.paid_at', + '<', + \Illuminate\Support\Carbon::createFromFormat('Y-m-d', $filters['paid_end']) + ->addDay() + ->toDateString(), + ); + } + + if (($filters['expense_category'] ?? '') !== '') { + $query->whereRaw( + $this->categoryExpression() . ' = ?', + [$filters['expense_category']], + ); + } + if (($filters['second_level'] ?? '') !== '') { + $query->whereRaw( + $this->secondLevelExpression() . ' = ?', + [$filters['second_level']], + ); + } + if (($filters['third_level'] ?? '') !== '') { + $query->whereRaw( + $this->thirdLevelExpression() . ' = ?', + [$filters['third_level']], + ); + } + if (($filters['allocation'] ?? '') !== '') { + $query->whereRaw( + $this->allocationExpression() . ' = ?', + [$filters['allocation']], + ); + } + if (($filters['fee_ratio'] ?? '') === 'in') { + $query->where('m.in_fee_ratio', 1); + } elseif (($filters['fee_ratio'] ?? '') === 'out') { + $query->where('m.in_fee_ratio', 0); + } elseif (($filters['fee_ratio'] ?? '') === 'unmapped') { + $query->whereNull('m.account_code'); + } + + foreach ([ + 'business_id' => 'd.business_id', + 'originator_department' => 'd.originator_department', + 'originator_name' => 'd.originator_name', + 'keyword' => 'd.purpose', + ] as $filter => $column) { + $value = trim((string) ($filters[$filter] ?? '')); + if ($value !== '') { + $query->where($column, 'like', '%' . $value . '%'); + } + } + + return $query; + } + + private function amountSplitExpression(): string + { + return 'COUNT(*) AS row_count, ' + . 'COUNT(DISTINCT d.business_id) AS approval_count, ' + . 'SUM(COALESCE(d.amount, 0)) AS amount_total, ' + . 'SUM(CASE WHEN m.in_fee_ratio = 1 THEN COALESCE(d.amount, 0) ELSE 0 END) AS in_fee_ratio_amount, ' + . 'SUM(CASE WHEN m.account_code IS NOT NULL AND m.in_fee_ratio = 0 ' + . 'THEN COALESCE(d.amount, 0) ELSE 0 END) AS non_fee_ratio_amount, ' + . 'SUM(CASE WHEN m.account_code IS NULL THEN COALESCE(d.amount, 0) ELSE 0 END) AS unmapped_amount'; + } + + private function categoryExpression(): string + { + return "COALESCE(NULLIF(m.expense_category, ''), '未映射科目')"; + } + + private function secondLevelExpression(): string + { + return "COALESCE(NULLIF(m.second_level, ''), '未映射科目')"; + } + + private function thirdLevelExpression(): string + { + return "COALESCE(NULLIF(m.third_level, ''), '未细分')"; + } + + private function feeRatioExpression(): string + { + return "CASE WHEN m.account_code IS NULL THEN '未映射科目' " + . "WHEN m.in_fee_ratio = 1 THEN '进费比' ELSE '不进费比' END"; + } + + private function allocationExpression(): string + { + return "COALESCE(NULLIF(m.allocation, ''), '未标注')"; + } + + private function groupKey(string $category, string $secondLevel): string + { + return sha1($category . "\0" . $secondLevel); + } + + /** @return array> */ + private function options(): array + { + $table = $this->connection->table('oa_process_account_mapping'); + $categories = (clone $table) + ->distinct() + ->orderBy('expense_category') + ->pluck('expense_category') + ->map(static fn (mixed $value): string => (string) $value) + ->values() + ->all(); + $secondLevels = (clone $table) + ->distinct() + ->orderBy('second_level') + ->pluck('second_level') + ->map(static fn (mixed $value): string => (string) $value) + ->values() + ->all(); + $thirdLevels = (clone $table) + ->distinct() + ->orderBy('third_level') + ->pluck('third_level') + ->map(static fn (mixed $value): string => (string) $value) + ->values() + ->all(); + $allocations = (clone $table) + ->whereNotNull('allocation') + ->where('allocation', '<>', '') + ->distinct() + ->orderBy('allocation') + ->pluck('allocation') + ->map(static fn (mixed $value): string => (string) $value) + ->values() + ->all(); + + $categories[] = '未映射科目'; + $secondLevels[] = '未映射科目'; + $thirdLevels[] = '未映射科目'; + $allocations[] = '未标注'; + $categories = $this->sortOptions($categories); + $secondLevels = $this->sortOptions($secondLevels); + $thirdLevels = $this->sortOptions($thirdLevels); + $allocations = $this->sortOptions($allocations); + + return [ + 'categories' => $categories, + 'second_levels' => $secondLevels, + 'third_levels' => $thirdLevels, + 'allocations' => $allocations, + 'fee_ratios' => self::FEE_RATIO_OPTIONS, + ]; + } + + /** @return list */ + private function sortOptions(array $values): array + { + $values = array_values(array_unique(array_filter( + $values, + static fn (string $value): bool => $value !== '', + ))); + sort($values, SORT_NATURAL | SORT_FLAG_CASE); + + return $values; + } + + /** @return array|array> */ + private function emptyOptions(): array + { + return [ + 'categories' => [], + 'second_levels' => [], + 'third_levels' => [], + 'allocations' => [], + 'fee_ratios' => self::FEE_RATIO_OPTIONS, + ]; + } + + /** @return array */ + private function emptySummary(): array + { + return [ + 'amount_total' => 0.0, + 'in_fee_ratio_amount' => 0.0, + 'non_fee_ratio_amount' => 0.0, + 'unmapped_amount' => 0.0, + 'row_count' => 0, + 'approval_count' => 0, + ]; + } + + /** @return array{0:string,1:string} */ + private static function dateRange(mixed $start, mixed $end): array + { + $normalize = static function (mixed $value): string { + $date = trim((string) $value); + if (preg_match('/^(\d{4})-(\d{2})-(\d{2})$/', $date, $parts) !== 1 + || ! checkdate((int) $parts[2], (int) $parts[3], (int) $parts[1])) { + return ''; + } + + return $date; + }; + $start = $normalize($start); + $end = $normalize($end); + if ($start !== '' && $end !== '' && $start > $end) { + [$start, $end] = [$end, $start]; + } + + return [$start, $end]; + } + + private static function perPage(mixed $value): int + { + $perPage = (int) $value; + + return in_array($perPage, self::PER_PAGE_OPTIONS, true) + ? $perPage + : self::DEFAULT_PER_PAGE; + } +} diff --git a/resources/data/oa_process_account_mapping.json b/resources/data/oa_process_account_mapping.json new file mode 100644 index 00000000..7611735a --- /dev/null +++ b/resources/data/oa_process_account_mapping.json @@ -0,0 +1,1912 @@ +[ + { + "account_code": "2202.01", + "account_name": "应付账款_供货商", + "expense_category": "报销", + "second_level": null, + "third_level": null, + "in_fee_ratio": false, + "allocation": null, + "source_row": 2 + }, + { + "account_code": "1221.01", + "account_name": "其他应收款_运营中心-种菜刷单", + "expense_category": "报销", + "second_level": null, + "third_level": null, + "in_fee_ratio": false, + "allocation": null, + "source_row": 3 + }, + { + "account_code": "2202.07", + "account_name": "应付账款_素板供应商", + "expense_category": "报销", + "second_level": null, + "third_level": null, + "in_fee_ratio": false, + "allocation": null, + "source_row": 4 + }, + { + "account_code": "1221.04", + "account_name": "其他应收款_借支销账", + "expense_category": "摊销", + "second_level": null, + "third_level": null, + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 5 + }, + { + "account_code": "2202.09", + "account_name": "应付账款_压贴厂供应商", + "expense_category": "报销", + "second_level": null, + "third_level": null, + "in_fee_ratio": false, + "allocation": null, + "source_row": 6 + }, + { + "account_code": "2241.01.12", + "account_name": "其他应付款-索菲亚服务费", + "expense_category": "摊销", + "second_level": null, + "third_level": null, + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 7 + }, + { + "account_code": "1701", + "account_name": "无形资产", + "expense_category": "摊销", + "second_level": null, + "third_level": null, + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 8 + }, + { + "account_code": "1012.02", + "account_name": "其他货币资金_可用余额", + "expense_category": "往来", + "second_level": null, + "third_level": null, + "in_fee_ratio": false, + "allocation": null, + "source_row": 9 + }, + { + "account_code": "2241.01.11", + "account_name": "其他应付款-顾家服务费", + "expense_category": "摊销", + "second_level": null, + "third_level": null, + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 10 + }, + { + "account_code": "1604.01.02", + "account_name": "在建工程_欧伯娜新厂房-经开区红联路产业园_工程施工", + "expense_category": "摊销", + "second_level": null, + "third_level": null, + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 11 + }, + { + "account_code": "2202.02", + "account_name": "应付账款_快递物流", + "expense_category": "报销", + "second_level": null, + "third_level": null, + "in_fee_ratio": false, + "allocation": null, + "source_row": 12 + }, + { + "account_code": "1221.23.01", + "account_name": "其他应收款_短期借款_供应商", + "expense_category": "报销", + "second_level": null, + "third_level": null, + "in_fee_ratio": false, + "allocation": null, + "source_row": 13 + }, + { + "account_code": "1606", + "account_name": "固定资产清理", + "expense_category": "摊销", + "second_level": null, + "third_level": null, + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 14 + }, + { + "account_code": "1221.02", + "account_name": "其他应收款_财务部-日常售后CRM打款", + "expense_category": "报销", + "second_level": null, + "third_level": null, + "in_fee_ratio": false, + "allocation": null, + "source_row": 15 + }, + { + "account_code": "2211.01", + "account_name": "应付职工薪酬_工资", + "expense_category": "管理费用", + "second_level": "职工薪酬", + "third_level": "工资", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 16 + }, + { + "account_code": "1123.24", + "account_name": "预付账款_万师傅安装费", + "expense_category": "报销", + "second_level": null, + "third_level": null, + "in_fee_ratio": false, + "allocation": null, + "source_row": 17 + }, + { + "account_code": "1123.27", + "account_name": "预付账款-品牌使用费(可退)", + "expense_category": "往来", + "second_level": null, + "third_level": null, + "in_fee_ratio": false, + "allocation": null, + "source_row": 18 + }, + { + "account_code": "1012.15", + "account_name": "其他货币资金_阿里巴巴数字营销账户", + "expense_category": "往来", + "second_level": null, + "third_level": null, + "in_fee_ratio": false, + "allocation": null, + "source_row": 19 + }, + { + "account_code": "1012.01", + "account_name": "其他货币资金_平台保证金", + "expense_category": "往来", + "second_level": null, + "third_level": null, + "in_fee_ratio": false, + "allocation": null, + "source_row": 20 + }, + { + "account_code": "5602.19.01", + "account_name": "管理费用_业务招待费_老板费用", + "expense_category": "管理费用", + "second_level": "业务招待费", + "third_level": "老板", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 21 + }, + { + "account_code": "2202.08", + "account_name": "应付账款_纸厂供应商", + "expense_category": "报销", + "second_level": null, + "third_level": null, + "in_fee_ratio": false, + "allocation": null, + "source_row": 22 + }, + { + "account_code": "2241.01.04", + "account_name": "其他应付款_预提费用_铭速安装费", + "expense_category": "报销", + "second_level": null, + "third_level": null, + "in_fee_ratio": false, + "allocation": null, + "source_row": 23 + }, + { + "account_code": "1012.10", + "account_name": "其他货币资金_京东快车账户", + "expense_category": "往来", + "second_level": null, + "third_level": null, + "in_fee_ratio": false, + "allocation": null, + "source_row": 24 + }, + { + "account_code": "1122.01.01.01", + "account_name": "应收账款_简尚_订单_订单应收", + "expense_category": "订单退款", + "second_level": null, + "third_level": null, + "in_fee_ratio": false, + "allocation": null, + "source_row": 25 + }, + { + "account_code": "1221.23.02", + "account_name": "其他应收款_短期借款_快递", + "expense_category": "报销", + "second_level": null, + "third_level": null, + "in_fee_ratio": false, + "allocation": null, + "source_row": 26 + }, + { + "account_code": "5404", + "account_name": "主营业务成本-板材", + "expense_category": "报销", + "second_level": null, + "third_level": null, + "in_fee_ratio": false, + "allocation": null, + "source_row": 27 + }, + { + "account_code": "5602.19.02", + "account_name": "管理费用_业务招待费_日常费用", + "expense_category": "管理费用", + "second_level": "业务招待费", + "third_level": "日常", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 28 + }, + { + "account_code": "5601.13.01", + "account_name": "销售费用-京东入仓-收派服务费", + "expense_category": "销售费用", + "second_level": "物流仓储费", + "third_level": "京东入仓-收派服务费", + "in_fee_ratio": true, + "allocation": null, + "source_row": 29 + }, + { + "account_code": "5602.43", + "account_name": "管理费用_培训费", + "expense_category": "管理费用", + "second_level": "职工薪酬", + "third_level": "职工教育经费", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 30 + }, + { + "account_code": "2202.04", + "account_name": "应付账款_配件发票", + "expense_category": "报销", + "second_level": null, + "third_level": null, + "in_fee_ratio": false, + "allocation": null, + "source_row": 31 + }, + { + "account_code": "5602.15", + "account_name": "管理费用_搬运费", + "expense_category": "管理费用", + "second_level": "物流仓储费", + "third_level": "搬运费", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 32 + }, + { + "account_code": "5601.05.03", + "account_name": "销售费用_营销费用_软件服务费", + "expense_category": "销售费用", + "second_level": "技术服务费", + "third_level": "软件服务费", + "in_fee_ratio": true, + "allocation": null, + "source_row": 33 + }, + { + "account_code": "5601.07", + "account_name": "销售费用_面单包装材料费", + "expense_category": "销售费用", + "second_level": "面单包装材料费", + "third_level": "面单包装材料费", + "in_fee_ratio": true, + "allocation": null, + "source_row": 34 + }, + { + "account_code": "1604.01.05", + "account_name": "在建工程_欧伯娜新厂房-经开区红联路产业园_其他费用", + "expense_category": "摊销", + "second_level": null, + "third_level": null, + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 35 + }, + { + "account_code": "1123.20", + "account_name": "预付账款_鲁班大师安装费", + "expense_category": "报销", + "second_level": null, + "third_level": null, + "in_fee_ratio": false, + "allocation": null, + "source_row": 36 + }, + { + "account_code": "5602.05", + "account_name": "管理费用_差旅费", + "expense_category": "管理费用", + "second_level": "差旅费", + "third_level": "日常差旅费", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 37 + }, + { + "account_code": "5602.18.06", + "account_name": "管理费用_福利费_聚餐费", + "expense_category": "管理费用", + "second_level": "职工薪酬", + "third_level": "福利费", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 38 + }, + { + "account_code": "1123.04", + "account_name": "预付账款_房租费", + "expense_category": "摊销", + "second_level": null, + "third_level": null, + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 39 + }, + { + "account_code": "2241.15", + "account_name": "其他应付款-老板车辆(苏D T7L08)", + "expense_category": "往来", + "second_level": null, + "third_level": null, + "in_fee_ratio": false, + "allocation": null, + "source_row": 40 + }, + { + "account_code": "1601.01", + "account_name": "固定资产_简尚", + "expense_category": "摊销", + "second_level": null, + "third_level": null, + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 41 + }, + { + "account_code": "5601.04.26", + "account_name": "京东云仓快递费", + "expense_category": "销售费用", + "second_level": "物流仓储费", + "third_level": "京东云仓-快递费", + "in_fee_ratio": true, + "allocation": null, + "source_row": 42 + }, + { + "account_code": "2241.01.05", + "account_name": "其他应付款_预提费用_货代费", + "expense_category": "销售费用", + "second_level": "货代费", + "third_level": null, + "in_fee_ratio": true, + "allocation": null, + "source_row": 43 + }, + { + "account_code": "5602.04", + "account_name": "管理费用_办公费", + "expense_category": "管理费用", + "second_level": "办公费", + "third_level": "办公费用品", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 44 + }, + { + "account_code": "5602.13.01", + "account_name": "管理费用_中介代理费_代理记账费", + "expense_category": "管理费用", + "second_level": "中介代理费", + "third_level": "代理记账费", + "in_fee_ratio": false, + "allocation": "核实进店铺", + "source_row": 45 + }, + { + "account_code": "5602.33.02", + "account_name": "管理费用_电费_办公", + "expense_category": "管理费用", + "second_level": "房租物业水电", + "third_level": "水电费", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 46 + }, + { + "account_code": "1405.06", + "account_name": "库存商品_线上代发", + "expense_category": "报销", + "second_level": null, + "third_level": null, + "in_fee_ratio": false, + "allocation": null, + "source_row": 47 + }, + { + "account_code": "2241.01.07", + "account_name": "其他应付款_预提费用_代理记账费", + "expense_category": "管理费用", + "second_level": "中介代理费", + "third_level": "代理记账费", + "in_fee_ratio": false, + "allocation": "核实进店铺", + "source_row": 48 + }, + { + "account_code": "1801.02.10", + "account_name": "长期待摊费用-装修费-天安数码城10号楼", + "expense_category": "摊销", + "second_level": null, + "third_level": null, + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 49 + }, + { + "account_code": "5602.11.03.28", + "account_name": "管理费用-AI算力软件", + "expense_category": "管理费用", + "second_level": "技术服务费", + "third_level": "AI算力软件", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 50 + }, + { + "account_code": "1012.11", + "account_name": "其他货币资金_万相台", + "expense_category": "往来", + "second_level": null, + "third_level": null, + "in_fee_ratio": false, + "allocation": null, + "source_row": 51 + }, + { + "account_code": "5602.18.08", + "account_name": "管理费用_福利费_其他福利", + "expense_category": "管理费用", + "second_level": "职工薪酬", + "third_level": "福利费", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 52 + }, + { + "account_code": "5602.37", + "account_name": "管理费用_咨询费", + "expense_category": "管理费用", + "second_level": "中介代理费", + "third_level": "咨询费", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 53 + }, + { + "account_code": "5602.49", + "account_name": "管理费用_装卸费", + "expense_category": "管理费用", + "second_level": "物流仓储费", + "third_level": "装卸费", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 54 + }, + { + "account_code": "5602.59", + "account_name": "管理费用-京喜快递费", + "expense_category": "管理费用", + "second_level": "物流仓储费", + "third_level": "京喜快递费", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 55 + }, + { + "account_code": "5602.13.03", + "account_name": "管理费用_中介代理费_公司注册费", + "expense_category": "管理费用", + "second_level": "中介代理费", + "third_level": "工商注册费", + "in_fee_ratio": false, + "allocation": "核实进店铺", + "source_row": 56 + }, + { + "account_code": "1122.01", + "account_name": "应收账款_简尚", + "expense_category": "订单退款", + "second_level": null, + "third_level": null, + "in_fee_ratio": false, + "allocation": null, + "source_row": 57 + }, + { + "account_code": "1012.14", + "account_name": "其他货币资金_拼多多直通车账户", + "expense_category": "往来", + "second_level": null, + "third_level": null, + "in_fee_ratio": false, + "allocation": null, + "source_row": 58 + }, + { + "account_code": "5602.42", + "account_name": "管理费用_临时人工费", + "expense_category": "管理费用", + "second_level": "职工薪酬", + "third_level": "临时人工费", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 59 + }, + { + "account_code": "5601.01.04", + "account_name": "销售费用_广告费用_推广广告费", + "expense_category": "销售费用", + "second_level": "推广费用", + "third_level": "推广广告费", + "in_fee_ratio": true, + "allocation": null, + "source_row": 60 + }, + { + "account_code": "5602.26", + "account_name": "管理费用_快递费", + "expense_category": "管理费用", + "second_level": "办公费", + "third_level": "快递费", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 61 + }, + { + "account_code": "5601.04.02", + "account_name": "销售费用_店铺日常费用_平台使用费", + "expense_category": "销售费用", + "second_level": "技术服务费", + "third_level": "店铺日常", + "in_fee_ratio": true, + "allocation": null, + "source_row": 62 + }, + { + "account_code": "5602.45", + "account_name": "管理费用_私车公用", + "expense_category": "管理费用", + "second_level": "差旅费", + "third_level": "私车公用", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 63 + }, + { + "account_code": "1012.16", + "account_name": "其他货币资金_抖音巨量千川", + "expense_category": "往来", + "second_level": null, + "third_level": null, + "in_fee_ratio": false, + "allocation": null, + "source_row": 64 + }, + { + "account_code": "5602.18.10", + "account_name": "管理费用_福利费_降本奖励", + "expense_category": "管理费用", + "second_level": "职工薪酬", + "third_level": "福利费", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 65 + }, + { + "account_code": "1221.31", + "account_name": "其他应收款-聚水谭", + "expense_category": "摊销", + "second_level": null, + "third_level": null, + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 66 + }, + { + "account_code": "5601.04.10", + "account_name": "销售费用_店铺日常费用_返点", + "expense_category": "销售费用", + "second_level": "平台佣金", + "third_level": "返点", + "in_fee_ratio": true, + "allocation": null, + "source_row": 67 + }, + { + "account_code": "5602.13.02", + "account_name": "管理费用_中介代理费_公司变更代理费", + "expense_category": "管理费用", + "second_level": "中介代理费", + "third_level": "工商变更费", + "in_fee_ratio": false, + "allocation": "核实进店铺", + "source_row": 68 + }, + { + "account_code": "5602.28", + "account_name": "管理费用_宽带费", + "expense_category": "管理费用", + "second_level": "办公费", + "third_level": "宽带费", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 69 + }, + { + "account_code": "5602.30", + "account_name": "管理费用_样品费", + "expense_category": "管理费用", + "second_level": "样品费", + "third_level": null, + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 70 + }, + { + "account_code": "1123.09.01", + "account_name": "预付账款_租赁费_叉车租赁", + "expense_category": "摊销", + "second_level": null, + "third_level": null, + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 71 + }, + { + "account_code": "1012.03", + "account_name": "其他货币资金_淘宝直通车账户", + "expense_category": "往来", + "second_level": null, + "third_level": null, + "in_fee_ratio": false, + "allocation": null, + "source_row": 72 + }, + { + "account_code": "5602.36", + "account_name": "管理费用_产品质检费", + "expense_category": "管理费用", + "second_level": "中介代理费", + "third_level": "产品质检费", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 73 + }, + { + "account_code": "1001.01", + "account_name": "库存现金_简尚", + "expense_category": "报销", + "second_level": null, + "third_level": null, + "in_fee_ratio": false, + "allocation": null, + "source_row": 74 + }, + { + "account_code": "5602.23", + "account_name": "管理费用_保洁费", + "expense_category": "管理费用", + "second_level": "保洁费", + "third_level": null, + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 75 + }, + { + "account_code": "5602.13.04", + "account_name": "管理费用_中介代理费_公司注销费", + "expense_category": "管理费用", + "second_level": "中介代理费", + "third_level": "工商注销费", + "in_fee_ratio": false, + "allocation": "核实进店铺", + "source_row": 76 + }, + { + "account_code": "1123.11", + "account_name": "预付账款_平台使用费", + "expense_category": "往来", + "second_level": null, + "third_level": null, + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 77 + }, + { + "account_code": "5602.57", + "account_name": "管理费用-低值易耗品", + "expense_category": "管理费用", + "second_level": "办公费", + "third_level": "低值易耗品", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 78 + }, + { + "account_code": "2241.08", + "account_name": "其他应付款_员工生育险", + "expense_category": "管理费用", + "second_level": "职工薪酬", + "third_level": "员工生育险", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 79 + }, + { + "account_code": "5601.13.03", + "account_name": "销售费用-京东入仓-仓储服务费-通用&耗材", + "expense_category": "销售费用", + "second_level": "物流仓储费", + "third_level": "京东入仓-通用&耗材", + "in_fee_ratio": true, + "allocation": null, + "source_row": 80 + }, + { + "account_code": "2241.17", + "account_name": "其他应付款-老板车辆(苏D FD1190)", + "expense_category": "往来", + "second_level": null, + "third_level": null, + "in_fee_ratio": false, + "allocation": null, + "source_row": 81 + }, + { + "account_code": "5602.01", + "account_name": "管理费用_修理费", + "expense_category": "管理费用", + "second_level": "安装修理费", + "third_level": null, + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 82 + }, + { + "account_code": "5602.09.01", + "account_name": "管理费用_房租费_仓库", + "expense_category": "管理费用", + "second_level": "房租物业水电", + "third_level": "房租", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 83 + }, + { + "account_code": "5602.10", + "account_name": "管理费用_员工社保费", + "expense_category": "管理费用", + "second_level": "职工薪酬", + "third_level": "社会保险费", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 84 + }, + { + "account_code": "1012.22", + "account_name": "其他货币资金-京喜推广", + "expense_category": "往来", + "second_level": null, + "third_level": null, + "in_fee_ratio": false, + "allocation": null, + "source_row": 85 + }, + { + "account_code": "5601.13.04", + "account_name": "销售费用-京东入仓-短驳费用", + "expense_category": "销售费用", + "second_level": "物流仓储费", + "third_level": "京东入仓-短驳费用", + "in_fee_ratio": true, + "allocation": null, + "source_row": 86 + }, + { + "account_code": "5602.27.02", + "account_name": "管理费用_装修费_办公", + "expense_category": "管理费用", + "second_level": "装修费", + "third_level": "公司", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 87 + }, + { + "account_code": "5602.18.05", + "account_name": "管理费用_福利费_评优奖励", + "expense_category": "管理费用", + "second_level": "职工薪酬", + "third_level": "福利费", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 88 + }, + { + "account_code": "5601.04.27", + "account_name": "销售费用-AI软件费", + "expense_category": "销售费用", + "second_level": "技术服务费", + "third_level": "AI算力软件", + "in_fee_ratio": true, + "allocation": null, + "source_row": 89 + }, + { + "account_code": "5602.47", + "account_name": "管理费用_工伤费", + "expense_category": "管理费用", + "second_level": "职工薪酬", + "third_level": "社会保险费", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 90 + }, + { + "account_code": "5602.60", + "account_name": "管理费用-安装费", + "expense_category": "管理费用", + "second_level": "安装修理费", + "third_level": null, + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 91 + }, + { + "account_code": "1123.07", + "account_name": "预付账款_物业费", + "expense_category": "摊销", + "second_level": null, + "third_level": null, + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 92 + }, + { + "account_code": "5602.09.03", + "account_name": "管理费用_房租费_宿舍", + "expense_category": "管理费用", + "second_level": "房租物业水电", + "third_level": "房租", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 93 + }, + { + "account_code": "5602.09.02", + "account_name": "管理费用_房租费_办公", + "expense_category": "管理费用", + "second_level": "房租物业水电", + "third_level": "房租", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 94 + }, + { + "account_code": "5601.04.01", + "account_name": "销售费用_店铺日常费用_店铺质检费", + "expense_category": "销售费用", + "second_level": "店铺运营费", + "third_level": "质检费", + "in_fee_ratio": true, + "allocation": null, + "source_row": 95 + }, + { + "account_code": "5601.04.07", + "account_name": "销售费用_店铺日常费用_快递费", + "expense_category": "销售费用", + "second_level": "物流仓储费", + "third_level": "快递费", + "in_fee_ratio": true, + "allocation": null, + "source_row": 96 + }, + { + "account_code": "5602.13.09", + "account_name": "管理费用_中介代理费_地址续费/迁移", + "expense_category": "管理费用", + "second_level": "中介代理费", + "third_level": "地址托管费", + "in_fee_ratio": false, + "allocation": "核实进店铺", + "source_row": 97 + }, + { + "account_code": "5602.33.01", + "account_name": "管理费用_电费_仓库", + "expense_category": "管理费用", + "second_level": "房租物业水电", + "third_level": "水电费", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 98 + }, + { + "account_code": "1801.02.12", + "account_name": "长期待摊费用-常州摄影中心", + "expense_category": "摊销", + "second_level": null, + "third_level": null, + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 99 + }, + { + "account_code": "5602.07.01", + "account_name": "管理费用_租用费_叉车租赁", + "expense_category": "管理费用", + "second_level": "车辆费用", + "third_level": "租赁费-叉车", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 100 + }, + { + "account_code": "2241.01.06", + "account_name": "其他应付款_预提费用_业务招待费", + "expense_category": "管理费用", + "second_level": "业务招待费", + "third_level": "老板", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 101 + }, + { + "account_code": "5602.12.08", + "account_name": "管理费用_税费税金_税金(开发票扣点)", + "expense_category": "管理费用", + "second_level": "税费税金", + "third_level": "税金(开发票扣点)", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 102 + }, + { + "account_code": "5602.56", + "account_name": "管理费用-设计服务费", + "expense_category": "管理费用", + "second_level": "中介代理费", + "third_level": "设计费", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 103 + }, + { + "account_code": "5601.04.05", + "account_name": "销售费用_店铺日常费用_样品费", + "expense_category": "销售费用", + "second_level": "店铺运营费", + "third_level": "样品费", + "in_fee_ratio": true, + "allocation": null, + "source_row": 104 + }, + { + "account_code": "5602.06", + "account_name": "管理费用_交通费", + "expense_category": "管理费用", + "second_level": "车辆费用", + "third_level": "交通费", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 105 + }, + { + "account_code": "5602.11.03.06", + "account_name": "管理费用_软件服务费_软件使用费_3D云渲染", + "expense_category": "管理费用", + "second_level": "技术服务费", + "third_level": "渲染", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 106 + }, + { + "account_code": "5602.39", + "account_name": "管理费用_摄影软装费", + "expense_category": "管理费用", + "second_level": "装修费", + "third_level": "其他", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 107 + }, + { + "account_code": "2241.01.09.01", + "account_name": "其他应付款_预提费用_社保费_简尚社保", + "expense_category": "摊销", + "second_level": null, + "third_level": null, + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 108 + }, + { + "account_code": "1221.03.01", + "account_name": "其他应收款_押金_房屋押金", + "expense_category": "摊销", + "second_level": null, + "third_level": null, + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 109 + }, + { + "account_code": "5602.03", + "account_name": "管理费用_电话费", + "expense_category": "管理费用", + "second_level": "办公费", + "third_level": "电话费", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 110 + }, + { + "account_code": "5601.04.16", + "account_name": "销售费用_店铺日常费用_差旅费", + "expense_category": "销售费用", + "second_level": "差旅费", + "third_level": "日常差旅费", + "in_fee_ratio": false, + "allocation": "进店铺", + "source_row": 111 + }, + { + "account_code": "1123.10.14", + "account_name": "预付账款_软件费_钉钉连结流扩容包", + "expense_category": "管理费用", + "second_level": "技术服务费", + "third_level": "钉钉", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 112 + }, + { + "account_code": "2241.01.10.03", + "account_name": "其他应付款_预提费用_公积金_济南公积金", + "expense_category": "管理费用", + "second_level": "职工薪酬", + "third_level": "住房公积金", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 113 + }, + { + "account_code": "5601.04.09", + "account_name": "销售费用_店铺日常费用_办公费", + "expense_category": "销售费用", + "second_level": "办公费", + "third_level": "直播间", + "in_fee_ratio": false, + "allocation": "进店铺", + "source_row": 114 + }, + { + "account_code": "5602.53", + "account_name": "管理费用-仓储费", + "expense_category": "管理费用", + "second_level": "物流仓储费", + "third_level": "仓储费", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 115 + }, + { + "account_code": "5602.11.03.99", + "account_name": "管理费用_软件服务费_软件使用费_其他软件(小金额不常用)", + "expense_category": "管理费用", + "second_level": "技术服务费", + "third_level": "小金额不常用", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 116 + }, + { + "account_code": "5602.32.05", + "account_name": "管理费用_汽车费用_车辆保险费", + "expense_category": "管理费用", + "second_level": "车辆费用", + "third_level": "车辆保险费", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 117 + }, + { + "account_code": "5601.03.03", + "account_name": "销售费用_售后费用_违约赔付", + "expense_category": "销售费用", + "second_level": "违约赔付", + "third_level": "商品质量补偿", + "in_fee_ratio": true, + "allocation": null, + "source_row": 118 + }, + { + "account_code": "5601.05.02", + "account_name": "销售费用_营销费用_平台服务费", + "expense_category": "销售费用", + "second_level": "技术服务费", + "third_level": "平台服务费", + "in_fee_ratio": true, + "allocation": null, + "source_row": 119 + }, + { + "account_code": "5602.31.02", + "account_name": "管理费用_物业管理费_办公", + "expense_category": "管理费用", + "second_level": "房租物业水电", + "third_level": "物业费", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 120 + }, + { + "account_code": "5601.05.04", + "account_name": "销售费用_营销费用_平台佣金", + "expense_category": "销售费用", + "second_level": "技术服务费", + "third_level": "平台佣金", + "in_fee_ratio": true, + "allocation": null, + "source_row": 121 + }, + { + "account_code": "5602.40", + "account_name": "管理费用_垃圾清理费", + "expense_category": "管理费用", + "second_level": "垃圾清理费", + "third_level": null, + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 122 + }, + { + "account_code": "5601.05.01.02.03", + "account_name": "销售费用_营销费用_店铺日常打款_售后补偿_买家原因", + "expense_category": "销售费用", + "second_level": "违约赔付", + "third_level": "买家原因", + "in_fee_ratio": true, + "allocation": null, + "source_row": 123 + }, + { + "account_code": "1123.10.99", + "account_name": "预付账款_软件费_其他", + "expense_category": "管理费用", + "second_level": "技术服务费", + "third_level": "软件服务费", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 124 + }, + { + "account_code": "5711", + "account_name": "营业外支出", + "expense_category": "营业外支出", + "second_level": "营业外支出", + "third_level": null, + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 125 + }, + { + "account_code": "5602.13.06", + "account_name": "管理费用_中介代理费_其他代办费", + "expense_category": "管理费用", + "second_level": "中介代理费", + "third_level": "其他代办费", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 126 + }, + { + "account_code": "5601.05.01.03", + "account_name": "销售费用_营销费用_店铺日常打款_好评返现", + "expense_category": "销售费用", + "second_level": "违约赔付", + "third_level": "好评返现", + "in_fee_ratio": true, + "allocation": null, + "source_row": 127 + }, + { + "account_code": "5601.01.02.03", + "account_name": "销售费用_广告费用_种菜费用_发空包", + "expense_category": "销售费用", + "second_level": "推广费用", + "third_level": "空包费", + "in_fee_ratio": true, + "allocation": null, + "source_row": 128 + }, + { + "account_code": "5602.29", + "account_name": "管理费用_专利费", + "expense_category": "管理费用", + "second_level": "中介代理费", + "third_level": "商标专利费", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 129 + }, + { + "account_code": "5602.02.02", + "account_name": "管理费用_保险费_雇主责任险", + "expense_category": "管理费用", + "second_level": "保险费", + "third_level": "雇主责任险", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 130 + }, + { + "account_code": "5602.18.09", + "account_name": "管理费用_福利费_内推奖励", + "expense_category": "管理费用", + "second_level": "职工薪酬", + "third_level": "福利费", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 131 + }, + { + "account_code": "5602.18.07", + "account_name": "管理费用_福利费_加班餐费", + "expense_category": "管理费用", + "second_level": "职工薪酬", + "third_level": "福利费", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 132 + }, + { + "account_code": "2241.01.01", + "account_name": "其他应付款_预提费用_水费", + "expense_category": "管理费用", + "second_level": "房租物业水电", + "third_level": "水电费", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 133 + }, + { + "account_code": "5602.18.03", + "account_name": "管理费用_福利费_体检", + "expense_category": "管理费用", + "second_level": "职工薪酬", + "third_level": "福利费", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 134 + }, + { + "account_code": "5601.12", + "account_name": "销售费用-运输装卸费", + "expense_category": "销售费用", + "second_level": "物流仓储费", + "third_level": "运输装卸费", + "in_fee_ratio": true, + "allocation": null, + "source_row": 135 + }, + { + "account_code": "5602.18.01", + "account_name": "管理费用_福利费_节日福利", + "expense_category": "管理费用", + "second_level": "职工薪酬", + "third_level": "福利费", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 136 + }, + { + "account_code": "5601.04.19", + "account_name": "销售费用_店铺日常费用_招待费", + "expense_category": "销售费用", + "second_level": "业务招待费", + "third_level": "日常", + "in_fee_ratio": true, + "allocation": null, + "source_row": 137 + }, + { + "account_code": "5601.05.01.02.08", + "account_name": "销售费用_营销费用_店铺日常打款_售后补偿_商家小额打款", + "expense_category": "销售费用", + "second_level": "违约赔付", + "third_level": "商家小额打款", + "in_fee_ratio": true, + "allocation": null, + "source_row": 138 + }, + { + "account_code": "5602.35.01", + "account_name": "管理费用_水费_仓库", + "expense_category": "管理费用", + "second_level": "房租物业水电", + "third_level": "水电费", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 139 + }, + { + "account_code": "5602.07.02", + "account_name": "管理费用_租用费_绿植租赁", + "expense_category": "管理费用", + "second_level": "房租物业水电", + "third_level": "绿植租赁", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 140 + }, + { + "account_code": "5602.20.01", + "account_name": "管理费用_商标费_商标注册费", + "expense_category": "管理费用", + "second_level": "中介代理费", + "third_level": "商标专利费", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 141 + }, + { + "account_code": "5602.11.02.01", + "account_name": "管理费用_软件服务费_软件开发费_工作平台", + "expense_category": "管理费用", + "second_level": "技术服务费", + "third_level": "工作平台", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 142 + }, + { + "account_code": "5602.12.02", + "account_name": "管理费用_税费税金_增值税", + "expense_category": "应交税费", + "second_level": "税费税金", + "third_level": "增值税", + "in_fee_ratio": false, + "allocation": "核实进店铺", + "source_row": 143 + }, + { + "account_code": "5602.13.10", + "account_name": "公司刻章费", + "expense_category": "管理费用", + "second_level": "办公费", + "third_level": "公司刻章费", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 144 + }, + { + "account_code": "1012.18", + "account_name": "其他货币资金-得物充值", + "expense_category": "往来", + "second_level": null, + "third_level": null, + "in_fee_ratio": false, + "allocation": null, + "source_row": 145 + }, + { + "account_code": "5601.03.07", + "account_name": "销售费用_售后费用_退货运费", + "expense_category": "销售费用", + "second_level": "物流仓储费", + "third_level": "退换货服务费", + "in_fee_ratio": true, + "allocation": null, + "source_row": 146 + }, + { + "account_code": "5602.34", + "account_name": "管理费用_叉车加油费", + "expense_category": "管理费用", + "second_level": "车辆费用", + "third_level": "燃油费-叉车", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 147 + }, + { + "account_code": "5602.32.03", + "account_name": "管理费用_汽车费用_过路费", + "expense_category": "管理费用", + "second_level": "车辆费用", + "third_level": "过路费", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 148 + }, + { + "account_code": "5602.12.06", + "account_name": "管理费用_税费税金_企业所得税", + "expense_category": "应交税费", + "second_level": "税费税金", + "third_level": "企业所得税", + "in_fee_ratio": false, + "allocation": "核实进店铺", + "source_row": 149 + }, + { + "account_code": "5602.32.04", + "account_name": "管理费用_汽车费用_保养维修费", + "expense_category": "管理费用", + "second_level": "车辆费用", + "third_level": "保养维修费", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 150 + }, + { + "account_code": "5601.05.01.02.01", + "account_name": "销售费用_营销费用_店铺日常打款_售后补偿_商品质量补偿", + "expense_category": "销售费用", + "second_level": "违约赔付", + "third_level": "商品质量补偿", + "in_fee_ratio": true, + "allocation": null, + "source_row": 151 + }, + { + "account_code": "5602.02.03", + "account_name": "管理费用_保险费_意外伤害险", + "expense_category": "管理费用", + "second_level": "保险费", + "third_level": "雇主责任险", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 152 + }, + { + "account_code": "5602.41", + "account_name": "管理费用_其他", + "expense_category": "管理费用", + "second_level": "办公费", + "third_level": "其他", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 153 + }, + { + "account_code": "5602.35.02", + "account_name": "管理费用_水费_办公", + "expense_category": "管理费用", + "second_level": "房租物业水电", + "third_level": "水电费", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 154 + }, + { + "account_code": "1123.10.05", + "account_name": "预付账款_软件费_金蝶", + "expense_category": "管理费用", + "second_level": "技术服务费", + "third_level": "财务", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 155 + }, + { + "account_code": "1221.08", + "account_name": "其他应收款_种菜物流单号", + "expense_category": "销售费用", + "second_level": "推广费用", + "third_level": "空包费", + "in_fee_ratio": true, + "allocation": null, + "source_row": 156 + }, + { + "account_code": "5602.20.02", + "account_name": "管理费用_商标费_商标续展费", + "expense_category": "管理费用", + "second_level": "中介代理费", + "third_level": "商标专利费", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 157 + }, + { + "account_code": "1601.02", + "account_name": "固定资产_仓储中心", + "expense_category": "摊销", + "second_level": null, + "third_level": null, + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 158 + }, + { + "account_code": "5602.11.01.02", + "account_name": "管理费用_软件服务费_服务器费用_工作平台", + "expense_category": "管理费用", + "second_level": "技术服务费", + "third_level": "工作平台", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 159 + }, + { + "account_code": "5602.11.03.18", + "account_name": "管理费用_软件服务费_软件使用费_钉钉连结流扩容包", + "expense_category": "管理费用", + "second_level": "技术服务费", + "third_level": "钉钉", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 160 + }, + { + "account_code": "5602.32.02", + "account_name": "管理费用_汽车费用_停车费", + "expense_category": "管理费用", + "second_level": "车辆费用", + "third_level": "停车费", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 161 + }, + { + "account_code": "5602.25", + "account_name": "管理费用_住房公积金", + "expense_category": "管理费用", + "second_level": "职工薪酬", + "third_level": "住房公积金", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 162 + }, + { + "account_code": "5601.14.05", + "account_name": "销售费用-中介代理费-店铺主体变更费", + "expense_category": "销售费用", + "second_level": "中介代理费", + "third_level": "店铺主体变更费", + "in_fee_ratio": false, + "allocation": "进店铺", + "source_row": 163 + }, + { + "account_code": "1123.06", + "account_name": "预付账款_国寿意外保险", + "expense_category": "管理费用", + "second_level": "保险费", + "third_level": "雇主责任险", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 164 + }, + { + "account_code": "5602.08", + "account_name": "管理费用_招聘费", + "expense_category": "管理费用", + "second_level": "职工薪酬", + "third_level": "招聘费", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 165 + }, + { + "account_code": "5601.05.01.04", + "account_name": "销售费用_营销费用_店铺日常打款_修改评价", + "expense_category": "销售费用", + "second_level": "违约赔付", + "third_level": "修改评价", + "in_fee_ratio": true, + "allocation": null, + "source_row": 166 + }, + { + "account_code": "5602.21.02", + "account_name": "管理费用_律师费_律师诉讼费", + "expense_category": "管理费用", + "second_level": "中介代理费", + "third_level": "律师费", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 167 + }, + { + "account_code": "1411.02", + "account_name": "周转材料_铁托盘", + "expense_category": "管理费用", + "second_level": "办公费", + "third_level": "低值易耗品", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 168 + }, + { + "account_code": "2241.01.10.01", + "account_name": "其他应付款_预提费用_公积金_简尚公积金", + "expense_category": "管理费用", + "second_level": "职工薪酬", + "third_level": "住房公积金", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 169 + }, + { + "account_code": "1012.19", + "account_name": "其他货币资金-淘工厂推广", + "expense_category": "往来", + "second_level": null, + "third_level": null, + "in_fee_ratio": false, + "allocation": null, + "source_row": 170 + }, + { + "account_code": "5601.05.01.02.05", + "account_name": "销售费用_营销费用_店铺日常打款_售后补偿_仓储原因", + "expense_category": "销售费用", + "second_level": "违约赔付", + "third_level": "仓储原因", + "in_fee_ratio": true, + "allocation": null, + "source_row": 171 + }, + { + "account_code": "5601.04.13", + "account_name": "销售费用_店铺日常费用_私车公用", + "expense_category": "销售费用", + "second_level": "差旅费", + "third_level": "私车公用", + "in_fee_ratio": false, + "allocation": "进店铺", + "source_row": 172 + }, + { + "account_code": "5602.31.03", + "account_name": "管理费用_物业管理费_宿舍", + "expense_category": "管理费用", + "second_level": "房租物业水电", + "third_level": "物业费", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 173 + }, + { + "account_code": "5602.12.04", + "account_name": "管理费用_税费税金_个人所得税", + "expense_category": "应交税费", + "second_level": "税费税金", + "third_level": "个人所得税", + "in_fee_ratio": false, + "allocation": "核实进店铺", + "source_row": 174 + }, + { + "account_code": "5601.05.05", + "account_name": "销售费用_营销费用_其他活动费用", + "expense_category": "销售费用", + "second_level": "推广费用", + "third_level": "其他推广费", + "in_fee_ratio": true, + "allocation": null, + "source_row": 175 + }, + { + "account_code": "1221.13", + "account_name": "其他应收款_个人所得税", + "expense_category": "管理费用", + "second_level": "职工薪酬", + "third_level": "个人所得税", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 176 + }, + { + "account_code": "5602.58", + "account_name": "翻包人工费", + "expense_category": "管理费用", + "second_level": "物流仓储费", + "third_level": "翻包人工费", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 177 + }, + { + "account_code": "5601.04.14", + "account_name": "销售费用_店铺日常费用_电话费", + "expense_category": "销售费用", + "second_level": "办公费", + "third_level": "电话费", + "in_fee_ratio": false, + "allocation": "进店铺", + "source_row": 178 + }, + { + "account_code": "5601.14.06", + "account_name": "销售费用-中介代理费-其他代办费", + "expense_category": "销售费用", + "second_level": "中介代理费", + "third_level": "其他代办费", + "in_fee_ratio": false, + "allocation": "进店铺", + "source_row": 179 + }, + { + "account_code": "5602.11.03.01", + "account_name": "管理费用_软件服务费_软件使用费_生意参谋(商业办公跟收纳整理专业版)", + "expense_category": "管理费用", + "second_level": "技术服务费", + "third_level": "生意参谋", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 180 + }, + { + "account_code": "5602.13.05", + "account_name": "管理费用_中介代理费_店铺主体变更费", + "expense_category": "管理费用", + "second_level": "中介代理费", + "third_level": "店铺主体变更费", + "in_fee_ratio": false, + "allocation": "核实进店铺", + "source_row": 181 + }, + { + "account_code": "5601.04.06", + "account_name": "销售费用_店铺日常费用_装修费", + "expense_category": "销售费用", + "second_level": "店铺运营费", + "third_level": "店铺测款费", + "in_fee_ratio": true, + "allocation": null, + "source_row": 182 + }, + { + "account_code": "5601.04.20", + "account_name": "销售费用_店铺日常费用_客户佣金", + "expense_category": "销售费用", + "second_level": "平台佣金", + "third_level": "客户", + "in_fee_ratio": true, + "allocation": null, + "source_row": 183 + }, + { + "account_code": "5602.12.03", + "account_name": "管理费用_税费税金_印花税", + "expense_category": "应交税费", + "second_level": "税费税金", + "third_level": "印花税", + "in_fee_ratio": false, + "allocation": "核实进店铺", + "source_row": 184 + }, + { + "account_code": "5602.12.07", + "account_name": "管理费用_税费税金_城建税及教育附加", + "expense_category": "应交税费", + "second_level": "税费税金", + "third_level": "城建税及教育附加", + "in_fee_ratio": false, + "allocation": "核实进店铺", + "source_row": 185 + }, + { + "account_code": "5601.04.04", + "account_name": "销售费用_店铺日常费用_电费", + "expense_category": "销售费用", + "second_level": "房租物业水电", + "third_level": "水电费", + "in_fee_ratio": false, + "allocation": "进店铺", + "source_row": 186 + }, + { + "account_code": "1123.09.02", + "account_name": "预付账款_租赁费_绿植租赁", + "expense_category": "管理费用", + "second_level": "房租物业水电", + "third_level": "绿植租赁", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 187 + }, + { + "account_code": "5601.06", + "account_name": "销售费用_安装费", + "expense_category": "销售费用", + "second_level": "店铺运营费", + "third_level": "安装费", + "in_fee_ratio": true, + "allocation": null, + "source_row": 188 + }, + { + "account_code": "5602.32.01", + "account_name": "管理费用_汽车费用_加油费", + "expense_category": "管理费用", + "second_level": "车辆费用", + "third_level": "燃油费", + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 189 + }, + { + "account_code": "5601.13.02", + "account_name": "销售费用-京东入仓-装卸服务费", + "expense_category": "销售费用", + "second_level": "物流仓储费", + "third_level": "京东入仓-装卸服务费", + "in_fee_ratio": true, + "allocation": null, + "source_row": 190 + }, + { + "account_code": "5603.03", + "account_name": "财务费用_账户管理费", + "expense_category": "财务费用", + "second_level": "账户管理费", + "third_level": null, + "in_fee_ratio": false, + "allocation": "分摊", + "source_row": 191 + }, + { + "account_code": "1001", + "account_name": "库存现金", + "expense_category": "往来", + "second_level": null, + "third_level": null, + "in_fee_ratio": false, + "allocation": null, + "source_row": 192 + } +] diff --git a/resources/views/business/pages/financial-operations/management-expenses.blade.php b/resources/views/business/pages/financial-operations/management-expenses.blade.php new file mode 100644 index 00000000..e0e78073 --- /dev/null +++ b/resources/views/business/pages/financial-operations/management-expenses.blade.php @@ -0,0 +1,1023 @@ +@php + $money = static fn (mixed $value): string => number_format((float) $value, 2); + $error ??= null; + $filters ??= []; + $summary ??= []; + $secondLevelSummary ??= []; + $thirdLevelSummary ??= []; + $options ??= []; + $perPageOptions ??= \Modules\EcommerceFinance\View\ManagementExpensesPageData::PER_PAGE_OPTIONS; + $detailColumns ??= \Modules\EcommerceFinance\View\ManagementExpensesPageData::DETAIL_COLUMNS; +@endphp + +@include('business.pages.partials.date-range-picker') + + + +
+
+
+

{{ $pageTitle ?? '管理费用' }}

+

+ 数据源为 OA 流程中付款状态为“已付款”的审批明细。科目规则来自“流程科目映射”, + 二级汇总区分进费比、不进费比和未映射科目;点击二级可查看三级和明细模板。 +

+
+
+ + @if ($error) +
+
{{ $error }}
+
+ @endif + +
+
已付款金额¥{{ $money($summary['amount_total'] ?? 0) }}
+
进费比金额¥{{ $money($summary['in_fee_ratio_amount'] ?? 0) }}
+
不进费比金额¥{{ $money($summary['non_fee_ratio_amount'] ?? 0) }}
+
审批单 / 明细行{{ number_format((int) ($summary['approval_count'] ?? 0)) }} / {{ number_format((int) ($summary['row_count'] ?? 0)) }}
+
+ +
+
+ + + 二级汇总 + + 点击二级行查看三级和已付款明细 +
+
+ + + + + + + + + + + + + + + + @forelse ($secondLevelSummary as $summaryRow) + + + + + + + + + + + + @empty + + @endforelse + +
费用大类二级进费比不进费比未映射合计金额审批单明细行三级
{{ $summaryRow['expense_category'] }}{{ $summaryRow['second_level'] }}{{ $money($summaryRow['in_fee_ratio_amount']) }}{{ $money($summaryRow['non_fee_ratio_amount']) }}{{ $money($summaryRow['unmapped_amount']) }}{{ $money($summaryRow['amount_total']) }}{{ number_format((int) $summaryRow['approval_count']) }}{{ number_format((int) $summaryRow['row_count']) }} + +
当前筛选条件没有已付款的 OA 流程明细。
+
+
+ +
+
+ +
+ + + + + + + 至 + + + + + + +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+ +
+
+ + + OA 已付款明细模板 + + 仅展示付款状态为“已付款”的流程明细 +
+
+ + + + @foreach ($detailColumns as $label) + + @endforeach + + + + @forelse ($rows as $row) + + + + + + + + + + + + @empty + + @endforelse + +
in_array($label, ['金额'], true)])>{{ $label }}
{{ $row['business_id'] }}{{ $row['originator_department'] ?: '-' }}{{ $row['purpose'] ?: '-' }}{{ $row['expense_category'] }}{{ $row['second_level'] }}{{ $row['third_level'] }}{{ $money($row['amount']) }} + + {{ $row['fee_ratio'] }} + + {{ $row['allocation'] }}
当前筛选条件没有已付款的 OA 流程明细。
+
+
+ 共 {{ number_format($rows->total()) }} 行 + +
+
+
+ + +
+
+ 二级明细 + 三级汇总与 OA 已付款明细 +
+ +
+
+ + +
+
+
+
+
+ + + + + + + + + + + + + + +
三级进费比不进费比未映射合计金额审批单明细行明细
+
+
+ +
+
+ + diff --git a/routes/admin.php b/routes/admin.php index 84da6a19..c9fea518 100644 --- a/routes/admin.php +++ b/routes/admin.php @@ -24,6 +24,7 @@ use Modules\EcommerceFinance\Http\Controllers\AlipayBills; use Modules\EcommerceFinance\Http\Controllers\DewuAccountBills; use Modules\EcommerceFinance\Http\Controllers\PinduoduoAccountBills; use Modules\EcommerceFinance\Http\Controllers\TaobaoWechatAccountBills; +use Modules\EcommerceFinance\Http\Controllers\ManagementExpenses; use Modules\EcommerceFinance\Http\Controllers\Api\GoodsReconciliations; use Modules\EcommerceFinance\Http\Controllers\Api\SupplierPayables; use Modules\EcommerceFinance\Http\Controllers\ThirdPartyWarehouseStorageSettlementExportController; @@ -638,6 +639,13 @@ Route::get('workspace/financial-operations/expense-details/item-summary', 'Busin ->middleware('business.page:financial-operations,expense-details') ->name('business.financial-operations.expense-details.item-summary'); +Route::get( + 'workspace/financial-operations/management-expenses/details', + [ManagementExpenses::class, 'details'], +) + ->middleware('business.page:financial-operations,management-expenses') + ->name('business.financial-operations.management-expenses.details'); + Route::get('workspace/financial-operations/billing-details/export', 'Business\Pages@exportBillingDetails') ->middleware('business.page:financial-operations,billing-details') ->name('business.financial-operations.billing-details.export'); diff --git a/tests/Feature/Business/ManagementExpensesPageTest.php b/tests/Feature/Business/ManagementExpensesPageTest.php new file mode 100644 index 00000000..08cc61e2 --- /dev/null +++ b/tests/Feature/Business/ManagementExpensesPageTest.php @@ -0,0 +1,118 @@ +user->attachPermission(Permission::where('name', 'read-admin-panel')->firstOrFail()); + $service = Mockery::mock(ManagementExpensesPageData::class); + $service->shouldReceive('page')->once()->andReturn([ + 'view' => 'business.pages.financial-operations.management-expenses', + 'pageTitle' => '管理费用', + 'rows' => new LengthAwarePaginator([ + [ + 'business_id' => '202610301323000477793', + 'originator_department' => '财务中心', + 'purpose' => '测试用途', + 'expense_category' => '管理费用', + 'second_level' => '办公费', + 'third_level' => '办公费用品', + 'amount' => 100.0, + 'fee_ratio' => '不进费比', + 'allocation' => '分摊', + ], + ], 1, 50, 1), + 'filters' => [ + 'paid_start' => '', 'paid_end' => '', 'expense_category' => '', + 'second_level' => '', 'third_level' => '', 'fee_ratio' => '', + 'allocation' => '', 'business_id' => '', 'originator_department' => '', + 'originator_name' => '', 'keyword' => '', + ], + 'summary' => [ + 'amount_total' => 100.0, 'in_fee_ratio_amount' => 0.0, + 'non_fee_ratio_amount' => 100.0, 'unmapped_amount' => 0.0, + 'row_count' => 1, 'approval_count' => 1, + ], + 'secondLevelSummary' => [[ + 'expense_category' => '管理费用', 'second_level' => '办公费', + 'in_fee_ratio_amount' => 0.0, 'non_fee_ratio_amount' => 100.0, + 'unmapped_amount' => 0.0, 'amount_total' => 100.0, + 'row_count' => 1, 'approval_count' => 1, + ]], + 'thirdLevelSummary' => [[ + 'expense_category' => '管理费用', 'second_level' => '办公费', + 'third_level' => '办公费用品', 'in_fee_ratio_amount' => 0.0, + 'non_fee_ratio_amount' => 100.0, 'unmapped_amount' => 0.0, + 'amount_total' => 100.0, 'row_count' => 1, 'approval_count' => 1, + ]], + 'options' => [ + 'categories' => ['管理费用'], 'second_levels' => ['办公费'], + 'third_levels' => ['办公费用品'], 'allocations' => ['分摊'], + 'fee_ratios' => ManagementExpensesPageData::FEE_RATIO_OPTIONS, + ], + 'perPageOptions' => ManagementExpensesPageData::PER_PAGE_OPTIONS, + 'detailColumns' => ManagementExpensesPageData::DETAIL_COLUMNS, + 'detailsUrl' => route( + 'business.financial-operations.management-expenses.details', + ['company_id' => company_id() ?: 1], + ), + 'error' => null, + ]); + $this->app->instance(ManagementExpensesPageData::class, $service); + + $this->loginAs()->get(route('business.pages.show', [ + 'section' => 'financial-operations', + 'page' => 'management-expenses', + ]))->assertOk() + ->assertSee('管理费用') + ->assertSee('二级汇总') + ->assertSee('OA 已付款明细模板') + ->assertSee('进费比') + ->assertSee('不进费比') + ->assertSee('是否分摊') + ->assertSee('办公费用品') + ->assertSee('202610301323000477793') + ->assertSee('data-me-open-group', false); + } + + public function test_details_endpoint_returns_template_rows(): void + { + $this->user->attachPermission(Permission::where('name', 'read-admin-panel')->firstOrFail()); + $service = Mockery::mock(ManagementExpensesPageData::class); + $service->shouldReceive('details')->once()->andReturn([ + 'rows' => [[ + 'business_id' => '202610301323000477793', + 'originator_department' => '财务中心', + 'purpose' => '测试用途', + 'expense_category' => '管理费用', + 'second_level' => '办公费', + 'third_level' => '办公费用品', + 'amount' => 100.0, + 'fee_ratio' => '不进费比', + 'allocation' => '分摊', + ]], + 'pagination' => ['current_page' => 1, 'last_page' => 1, 'per_page' => 50, 'total' => 1], + 'summary' => [ + 'amount_total' => 100.0, 'in_fee_ratio_amount' => 0.0, + 'non_fee_ratio_amount' => 100.0, 'unmapped_amount' => 0.0, + 'row_count' => 1, 'approval_count' => 1, + ], + ]); + $this->app->instance(ManagementExpensesPageData::class, $service); + + $this->loginAs()->getJson(route('business.financial-operations.management-expenses.details')) + ->assertOk() + ->assertJsonPath('success', true) + ->assertJsonPath('rows.0.business_id', '202610301323000477793') + ->assertJsonPath('rows.0.fee_ratio', '不进费比') + ->assertJsonPath('pagination.total', 1); + } +} diff --git a/tests/Unit/EcommerceFinance/ManagementExpensesPageDataTest.php b/tests/Unit/EcommerceFinance/ManagementExpensesPageDataTest.php new file mode 100644 index 00000000..ad5d3d3f --- /dev/null +++ b/tests/Unit/EcommerceFinance/ManagementExpensesPageDataTest.php @@ -0,0 +1,218 @@ + [ + 'driver' => 'sqlite', + 'database' => ':memory:', + 'prefix' => '', + ], + 'upstream_mirrors.connection' => 'business_mirror', + ]); + DB::purge('business_mirror'); + $this->createTables(); + $this->seedRows(); + $this->pageData = app(ManagementExpensesPageData::class); + } + + public function test_page_groups_only_paid_oa_rows_by_second_level_and_fee_ratio(): void + { + $data = $this->pageData->page(Request::create( + '/1/workspace/financial-operations/management-expenses', + 'GET', + )); + + $this->assertSame(5, $data['rows']->total()); + $this->assertSame(675.0, $data['summary']['amount_total']); + $this->assertSame(500.0, $data['summary']['in_fee_ratio_amount']); + $this->assertSame(125.0, $data['summary']['non_fee_ratio_amount']); + $this->assertSame(50.0, $data['summary']['unmapped_amount']); + $this->assertSame(5, $data['summary']['row_count']); + + $groups = collect($data['secondLevelSummary'])->keyBy( + static fn (array $row): string => $row['expense_category'] . '|' . $row['second_level'], + ); + $this->assertSame(125.0, $groups['管理费用|办公费']['amount_total']); + $this->assertSame(1, $groups['管理费用|办公费']['approval_count']); + $this->assertSame(500.0, $groups['销售费用|技术服务费']['in_fee_ratio_amount']); + $this->assertSame(50.0, $groups['未映射科目|未映射科目']['unmapped_amount']); + $this->assertCount(3, $data['secondLevelSummary']); + } + + public function test_detail_template_filters_and_paginates_paid_rows(): void + { + $data = $this->pageData->details(Request::create( + '/1/workspace/financial-operations/management-expenses/details', + 'GET', + [ + 'expense_category' => '管理费用', + 'second_level' => '办公费', + 'per_page' => 50, + ], + )); + + $this->assertSame(2, $data['pagination']['total']); + $this->assertSame(125.0, $data['summary']['amount_total']); + $this->assertSame( + ['审批编号', '部门', '用途', '分类', '二级', '三级', '金额', '是否进费比', '是否分摊'], + array_values(ManagementExpensesPageData::DETAIL_COLUMNS), + ); + $this->assertSame( + ['5602.04', '5602.04'], + array_column($data['rows'], 'business_id'), + ); + $this->assertSame('不进费比', $data['rows'][0]['fee_ratio']); + $this->assertSame('分摊', $data['rows'][0]['allocation']); + } + + public function test_unmapped_account_is_visible_instead_of_being_silently_dropped(): void + { + $data = $this->pageData->details(Request::create( + '/1/workspace/financial-operations/management-expenses/details', + 'GET', + ['fee_ratio' => 'unmapped'], + )); + + $this->assertSame(1, $data['pagination']['total']); + $this->assertSame('未映射科目', $data['rows'][0]['expense_category']); + $this->assertSame(50.0, $data['rows'][0]['amount']); + } + + public function test_workbook_mapping_snapshot_is_complete_and_unique(): void + { + $mapping = json_decode( + (string) file_get_contents(base_path('resources/data/oa_process_account_mapping.json')), + true, + 512, + JSON_THROW_ON_ERROR, + ); + + $this->assertCount(191, $mapping); + $this->assertCount(191, array_unique(array_column($mapping, 'account_code'))); + $this->assertSame(33, count(array_filter($mapping, static fn (array $row): bool => $row['in_fee_ratio']))); + $this->assertSame(125, count(array_filter($mapping, static fn (array $row): bool => $row['allocation'] !== null))); + $this->assertContains('分摊', array_column($mapping, 'allocation')); + $this->assertContains('核实进店铺', array_column($mapping, 'allocation')); + $this->assertContains('进店铺', array_column($mapping, 'allocation')); + } + + private function createTables(): void + { + Schema::connection('business_mirror')->create( + 'oa_process_account_mapping', + function (Blueprint $table): void { + $table->string('account_code', 64)->primary(); + $table->string('account_name', 255); + $table->string('expense_category', 100); + $table->string('second_level', 100); + $table->string('third_level', 100); + $table->boolean('in_fee_ratio')->default(false); + $table->string('allocation', 100)->nullable(); + $table->timestamps(); + }, + ); + Schema::connection('business_mirror')->create( + 'ding_process_detail_mirror', + function (Blueprint $table): void { + $table->bigIncrements('id'); + $table->string('business_id', 32); + $table->string('process_instance_id', 100)->nullable(); + $table->unsignedInteger('line_no'); + $table->string('account_code', 64)->nullable(); + $table->string('account_name', 255)->nullable(); + $table->string('originator_department', 255)->nullable(); + $table->string('originator_name', 100)->nullable(); + $table->string('status', 20)->nullable(); + $table->string('payment_source_state', 24)->nullable(); + $table->string('cashier_status', 32)->nullable(); + $table->text('purpose')->nullable(); + $table->decimal('amount', 18, 2)->nullable(); + $table->string('paid_at', 50)->nullable(); + $table->timestamps(); + }, + ); + } + + private function seedRows(): void + { + $now = now(); + DB::connection('business_mirror')->table('oa_process_account_mapping')->insert([ + [ + 'account_code' => '5602.04', + 'account_name' => '管理费用_办公费', + 'expense_category' => '管理费用', + 'second_level' => '办公费', + 'third_level' => '办公费用品', + 'in_fee_ratio' => false, + 'allocation' => '分摊', + 'created_at' => $now, + 'updated_at' => $now, + ], + [ + 'account_code' => '5601.05.03', + 'account_name' => '销售费用_营销费用_软件服务费', + 'expense_category' => '销售费用', + 'second_level' => '技术服务费', + 'third_level' => '软件服务费', + 'in_fee_ratio' => true, + 'allocation' => null, + 'created_at' => $now, + 'updated_at' => $now, + ], + ]); + DB::connection('business_mirror')->table('ding_process_detail_mirror')->insert([ + $this->row('5602.04', 1, 100, '已完成', 'completed', 'present', '2026-10-01'), + $this->row('5601.05.03', 1, 200, '已完成', 'completed', 'present', '2026-10-02'), + $this->row('5601.05.03', 1, 300, '审批中', 'completed', 'present', '2026-10-03'), + $this->row('5602.04', 1, 400, '审批中', 'pending', 'present', '2026-10-04'), + $this->row('9999.99', 1, 50, '已完成', 'completed', 'present', '2026-10-05'), + $this->row('5601.05.03', 1, 70, '已完成', 'not_applicable', 'not_applicable', '2026-10-06'), + $this->row('5602.04', 1, 25, '已完成', null, 'present', '2026-10-07'), + ]); + } + + /** @return array */ + private function row( + string $businessId, + int $lineNo, + float $amount, + string $status, + ?string $cashierStatus, + string $paymentSourceState, + string $paidAt, + ): array { + return [ + 'business_id' => $businessId, + 'process_instance_id' => 'process-' . $businessId, + 'line_no' => $lineNo, + 'account_code' => $businessId, + 'account_name' => '流程科目', + 'originator_department' => '财务中心', + 'originator_name' => '测试申请人', + 'status' => $status, + 'payment_source_state' => $paymentSourceState, + 'cashier_status' => $cashierStatus, + 'purpose' => '测试用途', + 'amount' => $amount, + 'paid_at' => $paidAt, + 'created_at' => now(), + 'updated_at' => now(), + ]; + } +}