Skip to content

Commit

Permalink
Fix: Typo in getCompountEntries method
Browse files Browse the repository at this point in the history
  • Loading branch information
ekmungai committed Aug 31, 2021
1 parent ca24ab5 commit 8bfd11b
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/Models/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ public function getAmountAttribute(): float
foreach ($this->getLineItems() as $lineItem) {
if($lineItem->credited != $this->credited){
$amount += $lineItem->amount * $lineItem->quantity;
if (!$lineItem->vat_inclusive) {
if (!is_null($lineItem->vat) && !$lineItem->vat_inclusive) {
$amount += $lineItem->amount * ($lineItem->vat->rate / 100) * $lineItem->quantity;
}
}
Expand All @@ -385,16 +385,14 @@ public function getAmountAttribute(): float
*/
public function getCompoundEntries()
{
if($this->isPosted){
$this->compoundEntries[
Transaction::getCompoundEntrytype($this->credited)
][$this->account_id] = floatval($this->main_account_amount);
$this->compoundEntries[
Transaction::getCompoundEntrytype($this->credited)
][$this->account_id] = floatval($this->main_account_amount);

foreach ($this->lineItems as $lineItem) {
$this->compoundEntries[
Transaction::getCompoundEntrytype($lineItem->credited)
][$lineItem->account_id] = $lineItem->amount * $lineItem->quantity;
}
foreach ($this->lineItems as $lineItem) {
$this->compoundEntries[
Transaction::getCompoundEntrytype($lineItem->credited)
][$lineItem->account_id] = $lineItem->amount * $lineItem->quantity;
}
return $this->compoundEntries;
}
Expand Down Expand Up @@ -717,6 +715,10 @@ public function save(array $options = []): bool
);
}

if (!isset($this->exchange_rate_id)) {
$this->exchange_rate_id = Auth::user()->entity->default_rate->id;
}

if ($this->isDirty('transaction_type') && $this->transaction_type != $this->getOriginal('transaction_type') && !is_null($this->id)) {
throw new InvalidTransactionType();
}
Expand Down

0 comments on commit 8bfd11b

Please sign in to comment.