Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
14.29% |
2 / 14 |
|
40.00% |
2 / 5 |
CRAP | |
0.00% |
0 / 1 |
AccountAbstract | |
14.29% |
2 / 14 |
|
40.00% |
2 / 5 |
72.97 | |
0.00% |
0 / 1 |
getId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getEntryById | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setL11n | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
20 | |||
getL11n | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
12 | |||
getEntriesByDate | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | /** |
3 | * Jingga |
4 | * |
5 | * PHP Version 8.1 |
6 | * |
7 | * @package Modules\Accounting\Models |
8 | * @copyright Dennis Eichhorn |
9 | * @license OMS License 2.0 |
10 | * @version 1.0.0 |
11 | * @link https://jingga.app |
12 | */ |
13 | declare(strict_types=1); |
14 | |
15 | namespace Modules\Accounting\Models; |
16 | |
17 | use phpOMS\Localization\BaseStringL11n; |
18 | use phpOMS\Localization\ISO639x1Enum; |
19 | |
20 | /** |
21 | * Account abstraction class. |
22 | * |
23 | * @package Modules\Accounting\Models |
24 | * @license OMS License 2.0 |
25 | * @link https://jingga.app |
26 | * @since 1.0.0 |
27 | */ |
28 | class AccountAbstract |
29 | { |
30 | /** |
31 | * Account ID. |
32 | * |
33 | * @var int |
34 | * @since 1.0.0 |
35 | */ |
36 | public int $id = 0; |
37 | |
38 | public string $account = ''; |
39 | |
40 | /* |
41 | * String l11n |
42 | * |
43 | * @var string | BaseStringL11n |
44 | * @since 1.0.0 |
45 | */ |
46 | public string | BaseStringL11n $l11n = ''; |
47 | |
48 | /** |
49 | * Summary account. |
50 | * |
51 | * @var null|int |
52 | * @since 1.0.0 |
53 | */ |
54 | public ?int $summaryAccount = null; |
55 | |
56 | /** |
57 | * Type. |
58 | * |
59 | * @var int |
60 | * @since 1.0.0 |
61 | */ |
62 | public int $type = AccountType::IMPERSONAL; |
63 | |
64 | public ?int $parent = null; |
65 | |
66 | /** |
67 | * Entry list. |
68 | * |
69 | * @var EntryInterface[] |
70 | * @since 1.0.0 |
71 | */ |
72 | protected array $entries = []; |
73 | |
74 | /** |
75 | * Get account id. |
76 | * |
77 | * @return int |
78 | * |
79 | * @since 1.0.0 |
80 | */ |
81 | public function getId() : int |
82 | { |
83 | return $this->id; |
84 | } |
85 | |
86 | /** |
87 | * Get entry. |
88 | * |
89 | * @param int $id Entry ID |
90 | * |
91 | * @return null|EntryInterface |
92 | * |
93 | * @since 1.0.0 |
94 | */ |
95 | public function getEntryById(int $id) : ?EntryInterface |
96 | { |
97 | return $this->entries[$id] ?? null; |
98 | } |
99 | |
100 | /** |
101 | * Set l11n |
102 | * |
103 | * @param string|BaseStringL11n $l11n Tag article l11n |
104 | * @param string $lang Language |
105 | * |
106 | * @return void |
107 | * |
108 | * @since 1.0.0 |
109 | */ |
110 | public function setL11n(string | BaseStringL11n $l11n, string $lang = ISO639x1Enum::_EN) : void |
111 | { |
112 | if ($l11n instanceof BaseStringL11n) { |
113 | $this->l11n = $l11n; |
114 | } elseif (isset($this->l11n) && $this->l11n instanceof BaseStringL11n) { |
115 | $this->l11n->content = $l11n; |
116 | $this->l11n->setLanguage($lang); |
117 | } else { |
118 | $this->l11n = new BaseStringL11n(); |
119 | $this->l11n->content = $l11n; |
120 | $this->l11n->setLanguage($lang); |
121 | } |
122 | } |
123 | |
124 | /** |
125 | * @return string |
126 | * |
127 | * @since 1.0.0 |
128 | */ |
129 | public function getL11n() : string |
130 | { |
131 | if (!isset($this->l11n)) { |
132 | return ''; |
133 | } |
134 | |
135 | return $this->l11n instanceof BaseStringL11n ? $this->l11n->content : $this->l11n; |
136 | } |
137 | |
138 | /** |
139 | * Get entry. |
140 | * |
141 | * @param \DateTime $start Interval start |
142 | * @param null|\DateTime $end Interval end |
143 | * @param int $dateType Date type by witch the entries should be filtered |
144 | * |
145 | * @return array |
146 | * |
147 | * @since 1.0.0 |
148 | */ |
149 | public function getEntriesByDate(\DateTime $start, \DateTime $end = null, int $dateType = TimeRangeType::RECEIPT_DATE) : array |
150 | { |
151 | return []; |
152 | } |
153 | } |