|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Amelia\Monzo\Models; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Transaction model. |
|
7
|
|
|
* |
|
8
|
|
|
* @property string $id The ID of this transaction. |
|
9
|
|
|
* @property \Carbon\Carbon $created The date this transaction was created. |
|
10
|
|
|
* @property string $description A description of this transaction. |
|
11
|
|
|
* @property int $amount The amount of this transaction, in pence, cents, etc. |
|
12
|
|
|
* @property string $currency ISO4217 currency code. |
|
13
|
|
|
* @property Merchant|string $merchant The merchant for this transaction. |
|
14
|
|
|
* @property string $notes A description of this transaction (The "notes" field from metadata). |
|
15
|
|
|
* @property array $metadata An arbitrary metadata array. |
|
16
|
|
|
* @property int $account_balance Account balance. In the current account, completely useless. |
|
17
|
|
|
* @property array $attachments An array of attachments on this transaction. |
|
18
|
|
|
* @property string $category The category of this transaction. |
|
19
|
|
|
* @property bool $is_load If this is an account topup (via card, etc). |
|
20
|
|
|
* @property \Carbon\Carbon|null $settled If this transaction has settled, the settlement date. |
|
21
|
|
|
* @property int $local_amount The local amount of this transaction, if different (tends to be current GBP value at the time). |
|
22
|
|
|
* @property string $local_currency The local currency of this transaction (ISO4217) |
|
23
|
|
|
* @property \Carbon\Carbon|null $updated A date this transaction was updated, or null. |
|
24
|
|
|
* @property string $account_id The account this transaction applies to. |
|
25
|
|
|
* @property array $counterparty An array of information about the other end of this transaction. |
|
26
|
|
|
* @property string $scheme The scheme this |
|
27
|
|
|
* @property string $dedupe_id An ID to prevent duplicates. |
|
28
|
|
|
* @property bool $originator N/A |
|
29
|
|
|
* @property bool $include_in_spending Include this transaction in the "spending" tab. |
|
30
|
|
|
* @property bool $pending If this transaction is pending. |
|
31
|
|
|
* @property bool $declined If this transaction was declined. |
|
32
|
|
|
* @property string|null $decline_reason A reason for declining, if present. |
|
33
|
|
|
*/ |
|
34
|
|
|
class Transaction extends Model |
|
35
|
|
|
{ |
|
36
|
|
|
/** |
|
37
|
|
|
* Casts for this model. |
|
38
|
|
|
* |
|
39
|
|
|
* @var array |
|
40
|
|
|
*/ |
|
41
|
|
|
protected $casts = [ |
|
42
|
|
|
'created' => 'date', |
|
43
|
|
|
'updated' => 'date', |
|
44
|
|
|
'settled' => 'date', |
|
45
|
|
|
'merchant' => Merchant::class, |
|
46
|
|
|
]; |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* Appended attributes. |
|
50
|
|
|
* |
|
51
|
|
|
* @var array |
|
52
|
|
|
*/ |
|
53
|
|
|
protected $appends = [ |
|
54
|
|
|
'pending', |
|
55
|
|
|
'declined', |
|
56
|
|
|
]; |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* Checks if this transaction is currently pending. |
|
60
|
|
|
* |
|
61
|
|
|
* @return bool |
|
62
|
|
|
*/ |
|
63
|
|
|
public function getPendingAttribute() |
|
64
|
|
|
{ |
|
65
|
|
|
return $this->settled === null; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* Checks if this transaction is currently pending. |
|
70
|
|
|
* |
|
71
|
|
|
* @return bool |
|
72
|
|
|
*/ |
|
73
|
|
|
public function getDeclinedAttribute() |
|
74
|
|
|
{ |
|
75
|
|
|
return $this->decline_reason !== null; |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|