1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 23:22:52 +01:00
invoiceninja/app/models/Payment.php

61 lines
1.1 KiB
PHP
Raw Normal View History

2013-11-26 13:45:07 +01:00
<?php
2013-12-04 17:20:14 +01:00
class Payment extends EntityModel
2013-11-26 13:45:07 +01:00
{
2015-01-11 13:30:08 +01:00
public function invoice()
{
return $this->belongsTo('Invoice')->withTrashed();
}
public function invitation()
{
return $this->belongsTo('Invitation');
}
public function client()
{
return $this->belongsTo('Client')->withTrashed();
}
public function account()
{
return $this->belongsTo('Account');
}
public function contact()
{
return $this->belongsTo('Contact');
}
public function getAmount()
{
return Utils::formatMoney($this->amount, $this->client->currency_id);
}
public function getName()
{
return trim("payment {$this->transaction_reference}");
}
public function getEntityType()
{
return ENTITY_PAYMENT;
}
2013-11-26 22:45:10 +01:00
}
2015-01-11 13:30:08 +01:00
Payment::created(function ($payment) {
Activity::createPayment($payment);
2014-01-14 12:52:56 +01:00
});
2015-01-11 13:30:08 +01:00
Payment::updating(function ($payment) {
Activity::updatePayment($payment);
2014-01-14 12:52:56 +01:00
});
2015-01-11 13:30:08 +01:00
Payment::deleting(function ($payment) {
Activity::archivePayment($payment);
2014-11-23 22:47:10 +01:00
});
2015-01-11 13:30:08 +01:00
Payment::restoring(function ($payment) {
Activity::restorePayment($payment);
});