Working on payment activities

This commit is contained in:
David Bomba 2025-05-01 15:40:54 +10:00
parent 912cb3aec5
commit 5b3155ea9e
1 changed files with 13 additions and 1 deletions

View File

@ -517,7 +517,7 @@ class Activity extends StaticModel
':recurring_invoice' => $translation = [substr($variable, 1) => [ 'label' => $this?->recurring_invoice?->number ?? '', 'hashed_id' => $this->recurring_invoice->hashed_id ?? '']],
':recurring_expense' => $translation = [substr($variable, 1) => [ 'label' => $this?->recurring_expense?->number ?? '', 'hashed_id' => $this->recurring_expense->hashed_id ?? '']],
':payment_amount' => $translation = [substr($variable, 1) => [ 'label' => Number::formatMoney($this?->payment?->amount, $this?->payment?->client ?? $this->company) ?? '', 'hashed_id' => '']],
':adjustment' => $translation = [substr($variable, 1) => [ 'label' => Number::formatMoney($this?->payment?->refunded, $this?->payment?->client ?? $this->company) ?? '', 'hashed_id' => '']],
':adjustment' => $translation = [substr($variable, 1) => [ 'label' => $this->getPaymentAdjustment($this?->payment), 'hashed_id' => '']],
':ip' => $translation = [ 'ip' => $this->ip ?? ''],
':contact' => $translation = $this->resolveContact(),
':notes' => $translation = [ 'notes' => $this->notes ?? ''],
@ -528,6 +528,18 @@ class Activity extends StaticModel
return $translation;
}
private function getPaymentAdjustment(?\App\Models\Payment $payment): string
{
if(!$payment)
return '';
preg_match('/:\s*(\d+)\s*-/', $this->notes, $matches);
$amount = $matches[1] ?? null;
return Number::formatMoney($amount ?? $payment->refunded, $payment?->client ?? $this->company);
}
private function resolveContact(): array
{
$contact = $this->contact ? $this->contact : $this->vendor_contact;