feat(client): add financial reports and ledger management
- Add trial balance and general ledger pages to client resource with interactive tables - Implement sales and expenses relation managers for client-specific transactions - Enhance transaction handling with proper tax and withholding calculations - Add date casting to Transaction model and define client relationships - Configure super admin role bypass in AppServiceProvider - Update Filament components and fix JavaScript formatting issues
This commit is contained in:
@@ -15,16 +15,27 @@ class CreateBalanceDTO extends Data
|
||||
public ?int $id = null,
|
||||
public ?int $ledger_id = null,
|
||||
public ?int $account_id = null,
|
||||
public ?int $branch_id = null
|
||||
public ?int $branch_id = null,
|
||||
public string $type = 'debit'
|
||||
) {
|
||||
$account = Account::query()->where('id', $this->account_id)->first();
|
||||
$account = Account::with('accountType')->where('id', $this->account_id)->first();
|
||||
|
||||
$currentBalance = $account ? $account->current_balance : 0;
|
||||
$normalBalance = strtolower($account->accountType->normal_balance ?? 'debit');
|
||||
$transactionType = strtolower($this->type);
|
||||
|
||||
if ($account->normal_balance == 'credit') {
|
||||
$this->balance = $currentBalance - $this->amount;
|
||||
} else {
|
||||
$this->balance = $currentBalance + $this->amount;
|
||||
if ($transactionType === 'debit') {
|
||||
if ($normalBalance === 'debit') {
|
||||
$this->balance = $currentBalance + $this->amount;
|
||||
} else {
|
||||
$this->balance = $currentBalance - $this->amount;
|
||||
}
|
||||
} else { // credit
|
||||
if ($normalBalance === 'credit') {
|
||||
$this->balance = $currentBalance + $this->amount;
|
||||
} else {
|
||||
$this->balance = $currentBalance - $this->amount;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,10 @@ class CreateLedgerDTO extends Data
|
||||
public array $data;
|
||||
|
||||
#[Computed]
|
||||
public int $transaction_id;
|
||||
public ?int $transaction_id = null;
|
||||
|
||||
#[Computed]
|
||||
public ?int $journal_id = null;
|
||||
|
||||
#[Computed]
|
||||
public int $account_id;
|
||||
@@ -35,16 +38,22 @@ class CreateLedgerDTO extends Data
|
||||
public float $amount,
|
||||
public ?Model $ledger = null,
|
||||
public ?Model $transaction = null,
|
||||
public ?Model $journal = null,
|
||||
public ?Model $account = null,
|
||||
public ?CreateBalanceDTO $balanceDTO = null,
|
||||
public ?string $type = null, // 'debit' or 'credit'
|
||||
) {
|
||||
$this->transaction_id = $this->transaction->id;
|
||||
$this->transaction_id = $this->transaction?->id;
|
||||
$this->journal_id = $this->journal?->id;
|
||||
$this->account_id = $this->account->id;
|
||||
$this->client_id = $this->transaction->branch->client_id;
|
||||
$this->credit_amount = $this->transaction->account_type == 'credit' ? $this->amount : 0.00;
|
||||
$this->debit_amount = $this->transaction->account_type == 'debit' ? $this->amount : 0.00;
|
||||
$this->description = $this->transaction->description;
|
||||
$this->client_id = $this->transaction?->branch->client_id ?? $this->journal?->client_id;
|
||||
|
||||
$accountType = $this->type ? strtolower($this->type) : strtolower($this->transaction?->account_type);
|
||||
|
||||
$this->data = Arr::except($this->toArray(), ['transaction', 'ledger', 'account', 'amount']);
|
||||
$this->credit_amount = $accountType == 'credit' ? $this->amount : 0.00;
|
||||
$this->debit_amount = $accountType == 'debit' ? $this->amount : 0.00;
|
||||
$this->description = $this->transaction?->description ?? $this->journal?->description;
|
||||
|
||||
$this->data = Arr::except($this->toArray(), ['transaction', 'journal', 'ledger', 'account', 'amount', 'type']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user