两个「终版」目录(供应商应付(终版)、快递应付(终版))改为独立数据: 保留原有导入、导出、查询、重置、编辑按钮和导入模板,数据初始为空、按表独立存放, 不再借用基础目录的页面与数据。 - 终版目录拥有自己的同名子页面与横向页签 - 新增终版按表数据的独立导入/导出/模板/编辑接口(数据集键 final:<目录>:<页面>) - 供应商终版 13 个页面、快递终版 4 个页面已接入 - 终版导入模板统一增加“月份”列,记录标识列改为选填
83 lines
2.9 KiB
PHP
83 lines
2.9 KiB
PHP
<?php
|
|
|
|
namespace Modules\EcommerceFinance\Services;
|
|
|
|
use Illuminate\Validation\ValidationException;
|
|
|
|
/**
|
|
* 「终版」目录的按表数据登记:确定每个页签的字段(决定导入模板与表格列)
|
|
* 以及数据标题;数据本身独立存放,与基础目录互不影响。
|
|
*/
|
|
class PayablesFinalRegistry
|
|
{
|
|
public const SECTION_SUPPLIER = 'supplier-payables-final';
|
|
|
|
public const SECTION_COURIER = 'courier-payables-final';
|
|
|
|
/** @var array<string,string> 供应商应付(终版)页签 */
|
|
private const SUPPLIER_TITLES = [
|
|
'product-prices' => '商品价格',
|
|
'payment-reconciliation' => '货款对账',
|
|
'return-reconciliation' => '退货对账',
|
|
'invoice-deductions' => '发票扣款',
|
|
'board-deductions' => '板材扣款',
|
|
'compensation-details' => '赔偿明细',
|
|
'advance-details' => '借支明细',
|
|
'sample-deductions' => '样品扣款',
|
|
'other-adjustments' => '其他扣款补款',
|
|
'delivery-unpriced' => '送货未定价',
|
|
'return-unpriced' => '退货未定价',
|
|
'dropshipping-express' => '代发快递',
|
|
'supplier-payables-report' => '供应商应付表',
|
|
];
|
|
|
|
/** 所有终版导入模板都带“月份”列,方便按月导入和查看。 */
|
|
private const MONTH_FIELD = ['summary_month' => ['label' => '月份', 'type' => 'month']];
|
|
|
|
public function __construct(
|
|
private readonly SupplierPayableMaintenanceRegistry $supplier,
|
|
private readonly ProductPriceWorkbookImporter $productPrices,
|
|
private readonly CourierPayableFinalRegistry $courier,
|
|
) {
|
|
}
|
|
|
|
public function supports(string $section, string $dataset): bool
|
|
{
|
|
return array_key_exists($dataset, $this->titles($section));
|
|
}
|
|
|
|
/** @return array<string,string> */
|
|
public function titles(string $section): array
|
|
{
|
|
return match ($section) {
|
|
self::SECTION_SUPPLIER => self::SUPPLIER_TITLES,
|
|
self::SECTION_COURIER => $this->courier->titles(),
|
|
default => [],
|
|
};
|
|
}
|
|
|
|
public function title(string $section, string $dataset): string
|
|
{
|
|
$titles = $this->titles($section);
|
|
if (! array_key_exists($dataset, $titles)) {
|
|
throw ValidationException::withMessages(['dataset' => '不支持该终版目录页面。']);
|
|
}
|
|
|
|
return $titles[$dataset];
|
|
}
|
|
|
|
/** @return array<string,array{label:string,type:string}> */
|
|
public function fields(string $section, string $dataset): array
|
|
{
|
|
$this->title($section, $dataset);
|
|
|
|
$fields = $section === self::SECTION_COURIER
|
|
? $this->courier->fields($dataset)
|
|
: ($dataset === 'product-prices'
|
|
? $this->productPrices->templateFields()
|
|
: $this->supplier->fields($dataset));
|
|
|
|
return self::MONTH_FIELD + $fields;
|
|
}
|
|
}
|