Closed AAUU-Ansari closed 5 months ago
Hi @AAUU-Ansari,
The idea behind having the transaction narration on the statement instead of line item narrations is tha since a single transaction can have multiple line items, displaying information about them on the statement would end up cluttering the report (think of 100 transactuions each with 10 items) making the report less legible and thus less useful. Another way of looking at it is just like the smallest unit of a financial statement balance is an Account, the smallest of an account statement is a transaction whose smallest unit in turn is a line item. This allows you to drill down all the figures of a financial statement by getting the details of each unit. Hope this helps.
Hi @ekmungai
In the function GetTransaction inside the Account Statement class I have made a small change after which I got the line items narration
add line:"$transaction->lineItems = LineItem::where('transaction_id','=',$transaction->id)->where('account_id','=',$this->account->id)->get();"
public function getTransactions_new(): array {
$entity = $this->account->entity;
$query = $this->account->transactionsQuery($this->period['startDate'], $this->period['endDate'], $this->currencyId);
$this->balances['opening'] = $this->account->openingBalance(ReportingPeriod::year($this->period['startDate'], $entity), $this->currencyId)[$this->currency->id];
$this->balances['closing'] += $this->balances['opening'];
$balance = $this->balances['opening'];
foreach ($query->get() as $transaction) {
$transaction->debit = $transaction->credit = 0;
$contribution = Ledger::contribution($this->account, $transaction->id, $this->currencyId);
$this->balances['closing'] += $contribution;
$balance += $contribution;
$transaction->balance = $balance;
$contribution > 0 ? $transaction->debit = abs($contribution) : $transaction->credit = abs($contribution);
$transaction->transactionType = config('ifrs')['transactions'][$transaction->transaction_type];
$transaction->transactionDate = Carbon::parse($transaction->transaction_date)->toFormattedDateString();
$transaction->lineItems = LineItem::where('transaction_id','=',$transaction->id)
->where('account_id','=',$this->account->id)->get();
array_push($this->transactions, $transaction);
}
return $this->transactions;
}
Hi @AAUU-Ansari ,
Do you mind putting your changes in the form of a PR?
Cheers, Edward
Hi @ekmungai
The account statement should display the narration of individual line items rather than the transaction narration. Currently, the statement only shows the transaction narration from the Transaction_table, which is not ideal. This is particularly problematic