feat: 发票基础信息支持店铺明细展开
This commit is contained in:
parent
ff2f6c9b90
commit
2150de8a9c
@ -28,6 +28,7 @@ use App\Models\Business\CourierQuoteSignature;
|
||||
use App\Models\Business\CourierQuoteVersion;
|
||||
use App\Models\Business\CourierSigningSubject;
|
||||
use App\Models\Business\InstallationDetail;
|
||||
use App\Models\Business\InvoiceBasicDetail;
|
||||
use App\Models\Business\InventoryWarehouseNameMapping;
|
||||
use App\Models\Business\Todo;
|
||||
use App\Business\CourierSurchargeAuditLogRepository;
|
||||
@ -3937,6 +3938,7 @@ class Pages extends Controller
|
||||
): array {
|
||||
$descriptor = null;
|
||||
$rows = collect();
|
||||
$invoiceBasicDetails = collect();
|
||||
$tabValue = null;
|
||||
$tabColumn = null;
|
||||
$upstreamError = null;
|
||||
@ -4099,6 +4101,26 @@ class Pages extends Controller
|
||||
}
|
||||
|
||||
$rows = $query->orderByDesc('id')->paginate(50)->withQueryString();
|
||||
|
||||
if (($section['slug'] ?? null) === 'invoice-management'
|
||||
&& ($page['slug'] ?? null) === 'basic-information') {
|
||||
try {
|
||||
$pageRows = $rows->getCollection();
|
||||
$periods = $pageRows->pluck('period')->filter()->unique()->values();
|
||||
$sellers = $pageRows->pluck('store_entity')->filter()->unique()->values();
|
||||
|
||||
if ($periods->isNotEmpty() && $sellers->isNotEmpty()) {
|
||||
$invoiceBasicDetails = InvoiceBasicDetail::query()
|
||||
->whereIn('period', $periods->all())
|
||||
->whereIn('seller_entity', $sellers->all())
|
||||
->orderByDesc('output_amount')
|
||||
->get()
|
||||
->groupBy(static fn (InvoiceBasicDetail $detail): string => $detail->seller_entity . '|' . $detail->period);
|
||||
}
|
||||
} catch (Throwable $exception) {
|
||||
report($exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4130,6 +4152,7 @@ class Pages extends Controller
|
||||
'inventoryUnmappedWarehouseError' => $inventoryUnmappedWarehouseError,
|
||||
'inventoryWarehouseMappingView' => $inventoryWarehouseMappingView,
|
||||
'receiptStats' => $receiptStats,
|
||||
'invoiceBasicDetails' => $invoiceBasicDetails,
|
||||
'payablesFinal' => $this->payablesFinalData($section, $page),
|
||||
];
|
||||
}
|
||||
|
||||
27
app/Models/Business/InvoiceBasicDetail.php
Normal file
27
app/Models/Business/InvoiceBasicDetail.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Business;
|
||||
|
||||
class InvoiceBasicDetail extends BusinessModel
|
||||
{
|
||||
protected $table = 'ak_biz_invoice_basic_details';
|
||||
|
||||
protected $fillable = [
|
||||
'company_id',
|
||||
'period',
|
||||
'seller_entity',
|
||||
'shop_name',
|
||||
'invoice_count',
|
||||
'output_amount',
|
||||
'tax_amount',
|
||||
'net_amount',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'company_id' => 'integer',
|
||||
'invoice_count' => 'integer',
|
||||
'output_amount' => 'decimal:2',
|
||||
'tax_amount' => 'decimal:2',
|
||||
'net_amount' => 'decimal:2',
|
||||
];
|
||||
}
|
||||
@ -0,0 +1,38 @@
|
||||
<?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::create('ak_biz_invoice_basic_details', function (Blueprint $table): void {
|
||||
$table->increments('id');
|
||||
$table->unsignedInteger('company_id')->default(1);
|
||||
$table->string('period', 10)->comment('期间,YYYY-MM');
|
||||
$table->string('seller_entity')->comment('销方开票主体');
|
||||
$table->string('shop_name')->comment('店铺名称');
|
||||
$table->unsignedInteger('invoice_count')->default(0)->comment('成功开票张数');
|
||||
$table->decimal('output_amount', 18, 2)->default(0)->comment('销项金额(含税)');
|
||||
$table->decimal('tax_amount', 18, 2)->default(0)->comment('税额');
|
||||
$table->decimal('net_amount', 18, 2)->default(0)->comment('不含税金额');
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(
|
||||
['company_id', 'period', 'seller_entity', 'shop_name'],
|
||||
'invoice_basic_details_unique'
|
||||
);
|
||||
$table->index(
|
||||
['company_id', 'period', 'seller_entity'],
|
||||
'invoice_basic_details_lookup'
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('ak_biz_invoice_basic_details');
|
||||
}
|
||||
};
|
||||
@ -9,6 +9,8 @@
|
||||
&& ($page['slug'] ?? null) === 'marketing-account-balance';
|
||||
$isStoreReceivingAccountsPage = ($section['slug'] ?? null) === 'fund-management'
|
||||
&& ($page['slug'] ?? null) === 'store-receiving-accounts';
|
||||
$isInvoiceBasicPage = ($section['slug'] ?? null) === 'invoice-management'
|
||||
&& ($page['slug'] ?? null) === 'basic-information';
|
||||
$isSupplierWorkspace = in_array($section['slug'] ?? null, ['supplier-payables', 'supplier-payables-final'], true);
|
||||
$supplierWorkspaceSection = $section;
|
||||
$isCourierFinalDirectory = ($section['slug'] ?? null) === 'courier-payables-final';
|
||||
@ -1054,6 +1056,49 @@
|
||||
@elseif ($pageView)
|
||||
@include($pageView)
|
||||
@elseif ($descriptor)
|
||||
@if ($isInvoiceBasicPage)
|
||||
<style>
|
||||
.invoice-expand-toggle {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 3px;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: var(--vip-content-accent-dark, #856632);
|
||||
font: inherit;
|
||||
cursor: pointer;
|
||||
}
|
||||
.invoice-expand-toggle .material-icons-outlined { font-size: 1rem; }
|
||||
.invoice-expand-toggle:hover { color: #6a5129; }
|
||||
.invoice-detail-row > td {
|
||||
padding: 0;
|
||||
background: #fffdf8;
|
||||
border-bottom: 1px solid var(--vip-border, #d8d2c7);
|
||||
}
|
||||
.invoice-detail-panel { padding: 0.75rem 1rem 1rem; }
|
||||
.invoice-detail-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
font-size: 0.78125rem;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
.invoice-detail-table th,
|
||||
.invoice-detail-table td {
|
||||
padding: 0.45rem 0.65rem;
|
||||
border-bottom: 1px solid var(--vip-border, #d8d2c7);
|
||||
text-align: left;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.invoice-detail-table th {
|
||||
background: var(--vip-content-accent-soft, #f7f0de);
|
||||
color: var(--vip-content-ink, #171717);
|
||||
font-size: 0.75rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
.invoice-detail-table .num { text-align: right; }
|
||||
</style>
|
||||
@endif
|
||||
<div class="biz-card mt-6">
|
||||
@if ($page['slug'] === 'installation-details')
|
||||
@include('business.pages.partials.date-range-picker')
|
||||
@ -1146,6 +1191,14 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
@forelse ($rows as $row)
|
||||
@php
|
||||
$invoiceDetailsForRow = $isInvoiceBasicPage
|
||||
? ($invoiceBasicDetails ?? collect())->get(($row->store_entity ?? '') . '|' . ($row->period ?? ''), collect())
|
||||
: collect();
|
||||
$showInvoiceDetails = $isInvoiceBasicPage
|
||||
&& \Illuminate\Support\Str::startsWith((string) ($row->store_name ?? ''), '多店铺(')
|
||||
&& $invoiceDetailsForRow->isNotEmpty();
|
||||
@endphp
|
||||
<tr @if ($page['slug'] === 'installation-details') class="installation-main-row" data-installation-row data-guid="{{ $row->related_guid ?? '' }}" tabindex="0" aria-label="查看安装商品明细" @endif>
|
||||
@if ($page['slug'] !== 'installation-details')<td>{{ $row->id }}</td>@endif
|
||||
@foreach ($descriptor->fields as $field)
|
||||
@ -1163,6 +1216,11 @@
|
||||
{{ \Illuminate\Support\Carbon::parse($val)->format('Y-m-d') }}
|
||||
@elseif ($field['currency'])
|
||||
{{ number_format((float) $val, 2) }}
|
||||
@elseif ($showInvoiceDetails && $field['name'] === 'store_name')
|
||||
<button type="button" class="invoice-expand-toggle" data-invoice-expand="{{ $row->id }}" aria-expanded="false">
|
||||
<span class="material-icons-outlined" aria-hidden="true">add</span>
|
||||
<span>{{ $val }}</span>
|
||||
</button>
|
||||
@else
|
||||
{{ $val }}
|
||||
@endif
|
||||
@ -1188,6 +1246,36 @@
|
||||
</td>
|
||||
@endunless
|
||||
</tr>
|
||||
@if ($showInvoiceDetails)
|
||||
<tr class="invoice-detail-row" data-invoice-detail="{{ $row->id }}" hidden>
|
||||
<td colspan="{{ count($descriptor->fields) + ($descriptor->readOnly ? 1 : 2) }}">
|
||||
<div class="invoice-detail-panel">
|
||||
<table class="invoice-detail-table" aria-label="{{ $row->store_entity }} {{ $row->period }} 店铺明细">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>店铺名称</th>
|
||||
<th class="num">开票张数</th>
|
||||
<th class="num">销项金额(含税)</th>
|
||||
<th class="num">税额</th>
|
||||
<th class="num">不含税金额</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($invoiceDetailsForRow->sortByDesc('output_amount') as $detail)
|
||||
<tr>
|
||||
<td>{{ $detail->shop_name }}</td>
|
||||
<td class="num">{{ number_format((int) $detail->invoice_count) }}</td>
|
||||
<td class="num">{{ number_format((float) $detail->output_amount, 2) }}</td>
|
||||
<td class="num">{{ number_format((float) $detail->tax_amount, 2) }}</td>
|
||||
<td class="num">{{ number_format((float) $detail->net_amount, 2) }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@endif
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="{{ count($descriptor->fields) + ($page['slug'] === 'installation-details' ? 0 : 1) + ($descriptor->readOnly ? 0 : 1) }}">
|
||||
@ -1277,6 +1365,24 @@
|
||||
</script>
|
||||
@endif
|
||||
|
||||
@if ($isInvoiceBasicPage)
|
||||
<script>
|
||||
(() => {
|
||||
document.querySelectorAll('[data-invoice-expand]').forEach((button) => {
|
||||
button.addEventListener('click', () => {
|
||||
const detailRow = document.querySelector('[data-invoice-detail="' + button.dataset.invoiceExpand + '"]');
|
||||
if (!detailRow) return;
|
||||
const willOpen = detailRow.hidden;
|
||||
detailRow.hidden = !willOpen;
|
||||
button.setAttribute('aria-expanded', willOpen ? 'true' : 'false');
|
||||
const icon = button.querySelector('.material-icons-outlined');
|
||||
if (icon) icon.textContent = willOpen ? 'remove' : 'add';
|
||||
});
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
@endif
|
||||
|
||||
</div>
|
||||
|
||||
@unless ($descriptor->readOnly)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user