|
@@ -55,6 +55,7 @@ public function overview(): array
|
|
|
'accounts_payable' => $this->pendingPayables(),
|
|
'accounts_payable' => $this->pendingPayables(),
|
|
|
'accounts_receivable' => $this->pendingReceivables(),
|
|
'accounts_receivable' => $this->pendingReceivables(),
|
|
|
'bank_balance_total' => $this->bankBalanceTotal(),
|
|
'bank_balance_total' => $this->bankBalanceTotal(),
|
|
|
|
|
+ 'stock_value' => $this->stockValue(),
|
|
|
'last_transactions' => $this->lastTransactions(),
|
|
'last_transactions' => $this->lastTransactions(),
|
|
|
'franchise_performance' => $this->franchisePerformance($monthStart, $monthEnd),
|
|
'franchise_performance' => $this->franchisePerformance($monthStart, $monthEnd),
|
|
|
];
|
|
];
|
|
@@ -107,6 +108,16 @@ private function pendingReceivables(): array
|
|
|
return ['value' => (float) $row->total, 'count' => (int) $row->qty];
|
|
return ['value' => (float) $row->total, 'count' => (int) $row->qty];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private function stockValue(): float
|
|
|
|
|
+ {
|
|
|
|
|
+ // Valor total do estoque = soma de (preço de venda x quantidade) de todos os
|
|
|
|
|
+ // produtos. Mesma base exibida por produto na aba de Produtos (price_sale * quantity).
|
|
|
|
|
+ return (float) DB::table('products')
|
|
|
|
|
+ ->whereNull('deleted_at')
|
|
|
|
|
+ ->selectRaw('COALESCE(SUM(price_sale * quantity), 0) AS total')
|
|
|
|
|
+ ->value('total');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private function bankBalanceTotal(): float
|
|
private function bankBalanceTotal(): float
|
|
|
{
|
|
{
|
|
|
// Saldo da rede = créditos (chegam no to_account) menos débitos (saem do from_account),
|
|
// Saldo da rede = créditos (chegam no to_account) menos débitos (saem do from_account),
|