Implement dark mode, bug report page, and schema dump
This commit is contained in:
@@ -10,6 +10,15 @@ class BankReconciliation extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected static function booted()
|
||||
{
|
||||
static::creating(function (BankReconciliation $model) {
|
||||
$model->adjusted_balance = $model->adjusted_balance ?? (float) $model->calculateAdjustedBalance();
|
||||
$model->discrepancy_amount = $model->discrepancy_amount ?? (float) $model->calculateDiscrepancy();
|
||||
$model->reconciliation_status = $model->reconciliation_status ?? self::STATUS_PENDING;
|
||||
});
|
||||
}
|
||||
|
||||
protected $fillable = [
|
||||
'reconciliation_month',
|
||||
'bank_statement_balance',
|
||||
@@ -113,7 +122,9 @@ class BankReconciliation extends Model
|
||||
*/
|
||||
public function calculateDiscrepancy(): float
|
||||
{
|
||||
return abs($this->adjusted_balance - $this->bank_statement_balance);
|
||||
$adjusted = $this->adjusted_balance ?? $this->calculateAdjustedBalance();
|
||||
|
||||
return abs($adjusted - floatval($this->bank_statement_balance));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -145,7 +156,8 @@ class BankReconciliation extends Model
|
||||
*/
|
||||
public function hasUnresolvedDiscrepancy(): bool
|
||||
{
|
||||
return $this->reconciliation_status === self::STATUS_DISCREPANCY;
|
||||
return $this->reconciliation_status === self::STATUS_DISCREPANCY
|
||||
|| $this->discrepancy_amount > 0.01;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -153,7 +165,7 @@ class BankReconciliation extends Model
|
||||
*/
|
||||
public function canBeReviewed(): bool
|
||||
{
|
||||
return $this->isPending() && $this->prepared_at !== null;
|
||||
return $this->isPending() && $this->reviewed_at === null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -183,30 +195,39 @@ class BankReconciliation extends Model
|
||||
public function getOutstandingItemsSummary(): array
|
||||
{
|
||||
$checksTotal = 0;
|
||||
$checksCount = 0;
|
||||
if ($this->outstanding_checks) {
|
||||
foreach ($this->outstanding_checks as $check) {
|
||||
$checksTotal += floatval($check['amount'] ?? 0);
|
||||
$checksCount++;
|
||||
}
|
||||
}
|
||||
|
||||
$depositsTotal = 0;
|
||||
$depositsCount = 0;
|
||||
if ($this->deposits_in_transit) {
|
||||
foreach ($this->deposits_in_transit as $deposit) {
|
||||
$depositsTotal += floatval($deposit['amount'] ?? 0);
|
||||
$depositsCount++;
|
||||
}
|
||||
}
|
||||
|
||||
$chargesTotal = 0;
|
||||
$chargesCount = 0;
|
||||
if ($this->bank_charges) {
|
||||
foreach ($this->bank_charges as $charge) {
|
||||
$chargesTotal += floatval($charge['amount'] ?? 0);
|
||||
$chargesCount++;
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'outstanding_checks_total' => $checksTotal,
|
||||
'deposits_in_transit_total' => $depositsTotal,
|
||||
'bank_charges_total' => $chargesTotal,
|
||||
'total_outstanding_checks' => $checksTotal,
|
||||
'outstanding_checks_count' => $checksCount,
|
||||
'total_deposits_in_transit' => $depositsTotal,
|
||||
'deposits_in_transit_count' => $depositsCount,
|
||||
'total_bank_charges' => $chargesTotal,
|
||||
'bank_charges_count' => $chargesCount,
|
||||
'net_adjustment' => $depositsTotal - $checksTotal - $chargesTotal,
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user