Failed Conditions
Push — master ( 5651e0...3036cd )
by
unknown
07:37
created

ExpenseClaim::accountingDocumentRemoved()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Application\Model;
6
7
use Application\DBAL\Types\ExpenseClaimStatusType;
8
use Application\Traits\HasDescription;
9
use Application\Traits\HasName;
10
use Application\Traits\HasRemarks;
11
use Doctrine\Common\Collections\ArrayCollection;
12
use Doctrine\Common\Collections\Collection;
13
use Doctrine\ORM\Mapping as ORM;
14
use GraphQL\Doctrine\Annotation as API;
15
16
/**
17
 * An expense claim to be refunded to an user
18
 *
19
 * @ORM\Entity(repositoryClass="Application\Repository\ExpenseClaimRepository")
20
 * @ORM\AssociationOverrides({
21
 *     @ORM\AssociationOverride(
22
 *         name="owner",
23
 *         joinColumns=@ORM\JoinColumn(nullable=false)
24
 *     )
25
 * })
26
 */
27
class ExpenseClaim extends AbstractModel
28
{
29
    use HasName;
30
    use HasDescription;
31
    use HasRemarks;
32
33
    /**
34
     * @var string
35
     *
36
     * @ORM\Column(type="decimal", precision=7, scale=2)
37
     */
38
    private $amount;
39
40
    /**
41
     * @var Collection
42
     * @ORM\OneToMany(targetEntity="Transaction", mappedBy="expenseClaim")
43
     */
44
    private $transactions;
45
46
    /**
47
     * @var Collection
48
     * @ORM\OneToMany(targetEntity="AccountingDocument", mappedBy="expenseClaim")
49
     */
50
    private $accountingDocuments;
51
52
    /**
53
     * @var string
54
     *
55
     * @ORM\Column(type="ExpenseClaimStatus", length=10, options={"default" = ExpenseClaimStatusType::NEW})
56
     */
57
    private $status = ExpenseClaimStatusType::NEW;
58
59
    /**
60
     * Constructor
61
     */
62 8
    public function __construct()
63
    {
64 8
        $this->transactions = new ArrayCollection();
65 8
        $this->accountingDocuments = new ArrayCollection();
66 8
    }
67
68
    /**
69
     * Set amount
70
     *
71
     * @param string $amount
72
     */
73 1
    public function setAmount(string $amount): void
74
    {
75 1
        $this->amount = $amount;
76 1
    }
77
78
    /**
79
     * Get amount
80
     *
81
     * @return string
82
     */
83
    public function getAmount(): string
84
    {
85
        return $this->amount;
86
    }
87
88
    /**
89
     * Set status
90
     *
91
     * @API\Input(type="ExpenseClaimStatus")
92
     *
93
     * @param string $status
94
     */
95 2
    public function setStatus(string $status): void
96
    {
97 2
        $this->status = $status;
98 2
    }
99
100
    /**
101
     * Get status
102
     *
103
     * @API\Field(type="ExpenseClaimStatus")
104
     *
105
     * @return string
106
     */
107 5
    public function getStatus(): string
108
    {
109 5
        return $this->status;
110
    }
111
112
    /**
113
     * Notify the expense claim that a transaction was added
114
     * This should only be called by Transaction::setExpenseClaim()
115
     *
116
     * @param Transaction $transaction
117
     */
118 1
    public function transactionAdded(Transaction $transaction): void
119
    {
120 1
        $this->transactions->add($transaction);
121 1
    }
122
123
    /**
124
     * Notify the expense claim that a transaction was removed
125
     * This should only be called by Transaction::setExpenseClaim()
126
     *
127
     * @param Transaction $transaction
128
     */
129 1
    public function transactionRemoved(Transaction $transaction): void
130
    {
131 1
        $this->transactions->removeElement($transaction);
132 1
    }
133
134
    /**
135
     * Get the transactions created from this expense claim
136
     *
137
     * @return Collection
138
     */
139 1
    public function getTransactions(): Collection
140
    {
141 1
        return $this->transactions;
142
    }
143
144
    /**
145
     * Notify the expense that an accounting document was added
146
     * This should only be called by AccountingDocument::setExpenseClaim()
147
     *
148
     * @param AccountingDocument $document
149
     */
150 7
    public function accountingDocumentAdded(AccountingDocument $document): void
151
    {
152 7
        $this->accountingDocuments->add($document);
153 7
    }
154
155
    /**
156
     * Notify the expense that an accounting document was removed
157
     * This should only be called by AccountingDocument::setExpenseClaim()
158
     *
159
     * @param AccountingDocument $document
160
     */
161 1
    public function accountingDocumentRemoved(AccountingDocument $document): void
162
    {
163 1
        $this->accountingDocuments->removeElement($document);
164 1
    }
165
166
    /**
167
     * Get accounting documents
168
     *
169
     * @return Collection
170
     */
171 1
    public function getAccountingDocuments(): Collection
172
    {
173 1
        return $this->accountingDocuments;
174
    }
175
}
176