1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 08:21:34 +02:00
invoiceninja/app/models/Payment.php

60 lines
945 B
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
{
public function invoice()
{
2014-02-19 14:28:29 +01:00
return $this->belongsTo('Invoice')->withTrashed();;
2013-11-26 13:45:07 +01:00
}
2013-12-01 21:58:25 +01:00
2013-12-07 19:45:00 +01:00
public function invitation()
{
return $this->belongsTo('Invitation');
}
2013-12-05 16:23:24 +01:00
public function client()
{
2014-02-19 14:28:29 +01:00
return $this->belongsTo('Client')->withTrashed();;
2013-12-05 16:23:24 +01:00
}
2014-01-29 11:41:38 +01:00
public function account()
{
return $this->belongsTo('Account');
}
public function contact()
{
return $this->belongsTo('Contact');
}
2014-07-15 22:36:40 +02:00
public function getAmount()
{
return Utils::formatMoney($this->amount, $this->client->currency_id);
}
2013-12-01 21:58:25 +01:00
public function getName()
{
2014-07-15 22:36:40 +02:00
return trim("payment {$this->transaction_reference}");
2013-12-01 21:58:25 +01:00
}
public function getEntityType()
{
return ENTITY_PAYMENT;
}
2013-11-26 22:45:10 +01:00
}
Payment::created(function($payment)
{
Activity::createPayment($payment);
2014-01-14 12:52:56 +01:00
});
Payment::updating(function($payment)
{
Activity::updatePayment($payment);
});
Payment::deleting(function($payment)
{
Activity::archivePayment($payment);
2013-11-26 22:45:10 +01:00
});