diff --git a/modules/EcommerceFinance/View/FinanceLedgerPageData.php b/modules/EcommerceFinance/View/FinanceLedgerPageData.php index fc541422..5d81d798 100644 --- a/modules/EcommerceFinance/View/FinanceLedgerPageData.php +++ b/modules/EcommerceFinance/View/FinanceLedgerPageData.php @@ -87,7 +87,10 @@ class FinanceLedgerPageData $tab = array_key_exists($tab, self::TABS) ? $tab : 'accounts'; $openingDate = (string) config('finance_ledger.opening_date', '2026-10-17'); $transactionView = $this->transactionView(); - $flowView = request('flows_view') === 'daily' ? 'daily' : 'summary'; + $requestedFlowView = trim((string) request('flows_view', 'summary')); + $flowView = in_array($requestedFlowView, ['summary', 'bank', 'non_store', 'daily'], true) + ? $requestedFlowView + : 'summary'; $flowPeriod = $this->dateRange('flows'); $transactionPeriod = $this->dateRange('txns'); $mappingPeriod = $this->dateRange('mapping'); @@ -591,7 +594,7 @@ class FinanceLedgerPageData { return $view === 'daily' ? $this->dailyFlows($period) - : $this->accountFlowSummary($period); + : $this->accountFlowSummary($period, $view); } private function dailyFlows(array $period): array @@ -629,13 +632,29 @@ class FinanceLedgerPageData ]; } - private function accountFlowSummary(array $period): array + private function accountFlowSummary(array $period, string $view = 'summary'): array { $customFields = $this->flowSummaryCustomFields(); $accountQuery = FinanceLedgerIndependentAccounts::exclude( $this->db()->table('fin_accounts as a'), 'a.account_short', ); + if ($view === 'bank') { + $accountQuery->where(function ($scope): void { + $scope->where(function ($account): void { + $account->whereNull('a.account_short') + ->orWhere('a.account_short', 'not like', '%支付宝%'); + })->where(function ($accountType): void { + $accountType->whereNull('a.account_type') + ->orWhere('a.account_type', 'not like', '%支付宝%'); + }); + }); + } elseif ($view === 'non_store') { + $accountQuery->where(function ($scope): void { + $scope->where('a.account_short', 'like', '%支付宝%') + ->orWhere('a.account_type', 'like', '%支付宝%'); + }); + } foreach (['flows_company' => 'a.company_name', 'flows_account' => 'a.account_short'] as $param => $column) { $value = trim((string) request($param, '')); if ($value !== '') { @@ -646,7 +665,7 @@ class FinanceLedgerPageData $accountRows = $accountQuery ->orderBy('a.company_name') ->orderBy('a.account_short') - ->get(['a.company_name', 'a.account_short']) + ->get(['a.company_name', 'a.account_short', 'a.account_type']) ->filter(static fn ($account): bool => trim((string) ($account->account_short ?? '')) !== '') ->unique('account_short') ->keyBy('account_short'); diff --git a/resources/views/business/pages/financial-ledger/ledger.blade.php b/resources/views/business/pages/financial-ledger/ledger.blade.php index 651df5cf..490451f8 100644 --- a/resources/views/business/pages/financial-ledger/ledger.blade.php +++ b/resources/views/business/pages/financial-ledger/ledger.blade.php @@ -71,6 +71,7 @@ $currentMonthEnd = now()->endOfMonth()->toDateString(); $flowPeriod = $ledgerFlowPeriod ?? ['from' => $currentMonthStart, 'to' => $currentMonthEnd]; $flowView = $ledgerFlowView ?? 'summary'; + $flowUsesAccountSummary = $flowView !== 'daily'; $flowSummaryCustomFields = $ledgerFlowSummaryCustomFields ?? []; $transactionPeriod = $ledgerTransactionPeriod ?? ['from' => $currentMonthStart, 'to' => $currentMonthEnd]; $mappingPeriod = $ledgerMappingPeriod ?? ['from' => $currentMonthStart, 'to' => $currentMonthEnd]; @@ -1079,10 +1080,12 @@