@@ -8,76 +8,76 @@ |
||
| 8 | 8 | */ |
| 9 | 9 | class StatementOfAccount |
| 10 | 10 | { |
| 11 | - /** |
|
| 12 | - * @var Statement[] |
|
| 13 | - */ |
|
| 14 | - protected $statements = array(); |
|
| 11 | + /** |
|
| 12 | + * @var Statement[] |
|
| 13 | + */ |
|
| 14 | + protected $statements = array(); |
|
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * Get statements |
|
| 18 | - * |
|
| 19 | - * @return Statement[] |
|
| 20 | - */ |
|
| 21 | - public function getStatements() |
|
| 22 | - { |
|
| 23 | - return $this->statements; |
|
| 24 | - } |
|
| 16 | + /** |
|
| 17 | + * Get statements |
|
| 18 | + * |
|
| 19 | + * @return Statement[] |
|
| 20 | + */ |
|
| 21 | + public function getStatements() |
|
| 22 | + { |
|
| 23 | + return $this->statements; |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Set statements |
|
| 28 | - * |
|
| 29 | - * @param array $statements |
|
| 30 | - * |
|
| 31 | - * @return $this |
|
| 32 | - */ |
|
| 33 | - public function setStatements(array $statements = null) |
|
| 34 | - { |
|
| 35 | - $this->statements = null == $statements ? array() : $statements; |
|
| 26 | + /** |
|
| 27 | + * Set statements |
|
| 28 | + * |
|
| 29 | + * @param array $statements |
|
| 30 | + * |
|
| 31 | + * @return $this |
|
| 32 | + */ |
|
| 33 | + public function setStatements(array $statements = null) |
|
| 34 | + { |
|
| 35 | + $this->statements = null == $statements ? array() : $statements; |
|
| 36 | 36 | |
| 37 | - return $this; |
|
| 38 | - } |
|
| 37 | + return $this; |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * @param Statement $statement |
|
| 42 | - */ |
|
| 43 | - public function addStatement(Statement $statement) |
|
| 44 | - { |
|
| 45 | - $this->statements[] = $statement; |
|
| 46 | - } |
|
| 40 | + /** |
|
| 41 | + * @param Statement $statement |
|
| 42 | + */ |
|
| 43 | + public function addStatement(Statement $statement) |
|
| 44 | + { |
|
| 45 | + $this->statements[] = $statement; |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * Gets statement for given date. |
|
| 50 | - * |
|
| 51 | - * @param string|\DateTime $date |
|
| 52 | - * @return Statement|null |
|
| 53 | - */ |
|
| 54 | - public function getStatementForDate($date) |
|
| 55 | - { |
|
| 56 | - if (is_string($date)) { |
|
| 57 | - $date = new \DateTime($date); |
|
| 58 | - } |
|
| 48 | + /** |
|
| 49 | + * Gets statement for given date. |
|
| 50 | + * |
|
| 51 | + * @param string|\DateTime $date |
|
| 52 | + * @return Statement|null |
|
| 53 | + */ |
|
| 54 | + public function getStatementForDate($date) |
|
| 55 | + { |
|
| 56 | + if (is_string($date)) { |
|
| 57 | + $date = new \DateTime($date); |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - foreach ($this->statements as $stmt) { |
|
| 61 | - if ($stmt->getDate() == $date) { |
|
| 62 | - return $stmt; |
|
| 63 | - } |
|
| 64 | - } |
|
| 60 | + foreach ($this->statements as $stmt) { |
|
| 61 | + if ($stmt->getDate() == $date) { |
|
| 62 | + return $stmt; |
|
| 63 | + } |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - return null; |
|
| 67 | - } |
|
| 66 | + return null; |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * Checks if a statement with given date exists. |
|
| 71 | - * |
|
| 72 | - * @param string|\DateTime $date |
|
| 73 | - * @return bool |
|
| 74 | - */ |
|
| 75 | - public function hasStatementForDate($date) |
|
| 76 | - { |
|
| 77 | - if (is_string($date)) { |
|
| 78 | - $date = new \DateTime($date); |
|
| 79 | - } |
|
| 69 | + /** |
|
| 70 | + * Checks if a statement with given date exists. |
|
| 71 | + * |
|
| 72 | + * @param string|\DateTime $date |
|
| 73 | + * @return bool |
|
| 74 | + */ |
|
| 75 | + public function hasStatementForDate($date) |
|
| 76 | + { |
|
| 77 | + if (is_string($date)) { |
|
| 78 | + $date = new \DateTime($date); |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - return null !== $this->getStatementForDate($date); |
|
| 82 | - } |
|
| 81 | + return null !== $this->getStatementForDate($date); |
|
| 82 | + } |
|
| 83 | 83 | } |
@@ -8,400 +8,400 @@ |
||
| 8 | 8 | */ |
| 9 | 9 | class Transaction |
| 10 | 10 | { |
| 11 | - const CD_CREDIT = 'credit'; |
|
| 12 | - const CD_DEBIT = 'debit'; |
|
| 13 | - const CD_CREDIT_CANCELLATION = 'credit_cancellation'; |
|
| 14 | - const CD_DEBIT_CANCELLATION = 'debit_cancellation'; |
|
| 15 | - |
|
| 16 | - /** |
|
| 17 | - * @var \DateTime|null |
|
| 18 | - */ |
|
| 19 | - protected $bookingDate; |
|
| 20 | - |
|
| 21 | - /** |
|
| 22 | - * @var \DateTime|null |
|
| 23 | - */ |
|
| 24 | - protected $valutaDate; |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * @var float |
|
| 28 | - */ |
|
| 29 | - protected $amount; |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * @var string |
|
| 33 | - */ |
|
| 34 | - protected $creditDebit; |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * @var string |
|
| 38 | - */ |
|
| 39 | - protected $bookingText; |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * @var string |
|
| 43 | - */ |
|
| 44 | - protected $description1; |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * @var string |
|
| 48 | - */ |
|
| 49 | - protected $description2; |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * Array keys are identifiers like "SVWZ" for the main description. |
|
| 53 | - * @var string[] |
|
| 54 | - */ |
|
| 55 | - protected $structuredDescription; |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * @var string |
|
| 59 | - */ |
|
| 60 | - protected $bankCode; |
|
| 61 | - |
|
| 62 | - /** |
|
| 63 | - * @var string |
|
| 64 | - */ |
|
| 65 | - protected $accountNumber; |
|
| 66 | - |
|
| 67 | - /** |
|
| 68 | - * @var string |
|
| 69 | - */ |
|
| 70 | - protected $name; |
|
| 71 | - |
|
| 72 | - /** |
|
| 73 | - * See https://www.bayernlb.de/internet/media/de/ir/downloads_1/zahlungsverkehr/formate_1/MT940_942.pdf page 451 / 8.2.6 Geschäftsvorfallcodes |
|
| 74 | - * @var string |
|
| 75 | - */ |
|
| 76 | - protected $transactionCode; |
|
| 77 | - |
|
| 78 | - /** |
|
| 79 | - * Get booking date. |
|
| 80 | - * |
|
| 81 | - * @deprecated Use getBookingDate() instead |
|
| 82 | - * @codeCoverageIgnore |
|
| 83 | - * @return \DateTime|null |
|
| 84 | - */ |
|
| 85 | - public function getDate() |
|
| 86 | - { |
|
| 87 | - return $this->getBookingDate(); |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - /** |
|
| 91 | - * Get booking date |
|
| 92 | - * |
|
| 93 | - * @return \DateTime|null |
|
| 94 | - */ |
|
| 95 | - public function getBookingDate() |
|
| 96 | - { |
|
| 97 | - return $this->bookingDate; |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - /** |
|
| 101 | - * Get date |
|
| 102 | - * |
|
| 103 | - * @return \DateTime|null |
|
| 104 | - */ |
|
| 105 | - public function getValutaDate() |
|
| 106 | - { |
|
| 107 | - return $this->valutaDate; |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - /** |
|
| 111 | - * Set booking date |
|
| 112 | - * |
|
| 113 | - * @param \DateTime|null $date |
|
| 114 | - * |
|
| 115 | - * @return $this |
|
| 116 | - */ |
|
| 117 | - public function setBookingDate(\DateTime $date = null) |
|
| 118 | - { |
|
| 119 | - $this->bookingDate = $date; |
|
| 120 | - |
|
| 121 | - return $this; |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - /** |
|
| 125 | - * Set valuta date |
|
| 126 | - * |
|
| 127 | - * @param \DateTime|null $date |
|
| 128 | - * |
|
| 129 | - * @return $this |
|
| 130 | - */ |
|
| 131 | - public function setValutaDate(\DateTime $date = null) |
|
| 132 | - { |
|
| 133 | - $this->valutaDate = $date; |
|
| 134 | - |
|
| 135 | - return $this; |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - /** |
|
| 139 | - * Get the signed amount based on credit/debit setting. |
|
| 140 | - * Debits and canceled credits have a negative sign. |
|
| 141 | - * @return float |
|
| 142 | - */ |
|
| 143 | - public function getSignedAmount() |
|
| 144 | - { |
|
| 145 | - switch ($this->creditDebit) { |
|
| 146 | - case Transaction::CD_DEBIT: |
|
| 147 | - case Transaction::CD_CREDIT_CANCELLATION: |
|
| 148 | - return -1 * $this->amount; |
|
| 149 | - default: |
|
| 150 | - return $this->amount; |
|
| 151 | - } |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - /** |
|
| 155 | - * Get amount |
|
| 156 | - * |
|
| 157 | - * @return float |
|
| 158 | - */ |
|
| 159 | - public function getAmount() |
|
| 160 | - { |
|
| 161 | - return $this->amount; |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - /** |
|
| 165 | - * Set amount |
|
| 166 | - * |
|
| 167 | - * @param float $amount |
|
| 168 | - * |
|
| 169 | - * @return $this |
|
| 170 | - */ |
|
| 171 | - public function setAmount($amount) |
|
| 172 | - { |
|
| 173 | - $this->amount = (float) $amount; |
|
| 174 | - |
|
| 175 | - return $this; |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - /** |
|
| 179 | - * Get creditDebit |
|
| 180 | - * |
|
| 181 | - * @return string |
|
| 182 | - */ |
|
| 183 | - public function getCreditDebit() |
|
| 184 | - { |
|
| 185 | - return $this->creditDebit; |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - /** |
|
| 189 | - * Set creditDebit |
|
| 190 | - * |
|
| 191 | - * @param string $creditDebit |
|
| 192 | - * |
|
| 193 | - * @return $this |
|
| 194 | - */ |
|
| 195 | - public function setCreditDebit($creditDebit) |
|
| 196 | - { |
|
| 197 | - $this->creditDebit = $creditDebit; |
|
| 198 | - |
|
| 199 | - return $this; |
|
| 200 | - } |
|
| 201 | - |
|
| 202 | - /** |
|
| 203 | - * Get bookingText |
|
| 204 | - * |
|
| 205 | - * @return string |
|
| 206 | - */ |
|
| 207 | - public function getBookingText() |
|
| 208 | - { |
|
| 209 | - return $this->bookingText; |
|
| 210 | - } |
|
| 211 | - |
|
| 212 | - /** |
|
| 213 | - * Set bookingText |
|
| 214 | - * |
|
| 215 | - * @param string $bookingText |
|
| 216 | - * |
|
| 217 | - * @return $this |
|
| 218 | - */ |
|
| 219 | - public function setBookingText($bookingText) |
|
| 220 | - { |
|
| 221 | - $this->bookingText = (string) $bookingText; |
|
| 222 | - |
|
| 223 | - return $this; |
|
| 224 | - } |
|
| 225 | - |
|
| 226 | - /** |
|
| 227 | - * Get description1 |
|
| 228 | - * |
|
| 229 | - * @return string |
|
| 230 | - */ |
|
| 231 | - public function getDescription1() |
|
| 232 | - { |
|
| 233 | - return $this->description1; |
|
| 234 | - } |
|
| 235 | - |
|
| 236 | - /** |
|
| 237 | - * Set description1 |
|
| 238 | - * |
|
| 239 | - * @param string $description1 |
|
| 240 | - * |
|
| 241 | - * @return $this |
|
| 242 | - */ |
|
| 243 | - public function setDescription1($description1) |
|
| 244 | - { |
|
| 245 | - $this->description1 = (string) $description1; |
|
| 246 | - |
|
| 247 | - return $this; |
|
| 248 | - } |
|
| 249 | - |
|
| 250 | - /** |
|
| 251 | - * Get description2 |
|
| 252 | - * |
|
| 253 | - * @return string |
|
| 254 | - */ |
|
| 255 | - public function getDescription2() |
|
| 256 | - { |
|
| 257 | - return $this->description2; |
|
| 258 | - } |
|
| 259 | - |
|
| 260 | - /** |
|
| 261 | - * Set description2 |
|
| 262 | - * |
|
| 263 | - * @param string $description2 |
|
| 264 | - * |
|
| 265 | - * @return $this |
|
| 266 | - */ |
|
| 267 | - public function setDescription2($description2) |
|
| 268 | - { |
|
| 269 | - $this->description2 = (string) $description2; |
|
| 270 | - |
|
| 271 | - return $this; |
|
| 272 | - } |
|
| 273 | - |
|
| 274 | - /** |
|
| 275 | - * Get structuredDescription |
|
| 276 | - * |
|
| 277 | - * @return string[] |
|
| 278 | - */ |
|
| 279 | - public function getStructuredDescription() |
|
| 280 | - { |
|
| 281 | - return $this->structuredDescription; |
|
| 282 | - } |
|
| 283 | - |
|
| 284 | - /** |
|
| 285 | - * Set structuredDescription |
|
| 286 | - * |
|
| 287 | - * @param string[] $structuredDescription |
|
| 288 | - * |
|
| 289 | - * @return $this |
|
| 290 | - */ |
|
| 291 | - public function setStructuredDescription($structuredDescription) |
|
| 292 | - { |
|
| 293 | - $this->structuredDescription = $structuredDescription; |
|
| 294 | - |
|
| 295 | - return $this; |
|
| 296 | - } |
|
| 297 | - |
|
| 298 | - /** |
|
| 299 | - * Get the main description (SVWZ) |
|
| 300 | - * |
|
| 301 | - * @return string |
|
| 302 | - */ |
|
| 303 | - public function getMainDescription() |
|
| 304 | - { |
|
| 305 | - if (array_key_exists('SVWZ', $this->structuredDescription)) { |
|
| 306 | - return $this->structuredDescription['SVWZ']; |
|
| 307 | - } else { |
|
| 308 | - return ''; |
|
| 309 | - } |
|
| 310 | - } |
|
| 311 | - |
|
| 312 | - /** |
|
| 313 | - * Get bankCode |
|
| 314 | - * |
|
| 315 | - * @return string |
|
| 316 | - */ |
|
| 317 | - public function getBankCode() |
|
| 318 | - { |
|
| 319 | - return $this->bankCode; |
|
| 320 | - } |
|
| 321 | - |
|
| 322 | - /** |
|
| 323 | - * Set bankCode |
|
| 324 | - * |
|
| 325 | - * @param string $bankCode |
|
| 326 | - * |
|
| 327 | - * @return $this |
|
| 328 | - */ |
|
| 329 | - public function setBankCode($bankCode) |
|
| 330 | - { |
|
| 331 | - $this->bankCode = (string) $bankCode; |
|
| 332 | - |
|
| 333 | - return $this; |
|
| 334 | - } |
|
| 335 | - |
|
| 336 | - /** |
|
| 337 | - * Get accountNumber |
|
| 338 | - * |
|
| 339 | - * @return string |
|
| 340 | - */ |
|
| 341 | - public function getAccountNumber() |
|
| 342 | - { |
|
| 343 | - return $this->accountNumber; |
|
| 344 | - } |
|
| 345 | - |
|
| 346 | - /** |
|
| 347 | - * Set accountNumber |
|
| 348 | - * |
|
| 349 | - * @param string $accountNumber |
|
| 350 | - * |
|
| 351 | - * @return $this |
|
| 352 | - */ |
|
| 353 | - public function setAccountNumber($accountNumber) |
|
| 354 | - { |
|
| 355 | - $this->accountNumber = (string) $accountNumber; |
|
| 356 | - |
|
| 357 | - return $this; |
|
| 358 | - } |
|
| 359 | - |
|
| 360 | - /** |
|
| 361 | - * Get name |
|
| 362 | - * |
|
| 363 | - * @return string |
|
| 364 | - */ |
|
| 365 | - public function getName() |
|
| 366 | - { |
|
| 367 | - return $this->name; |
|
| 368 | - } |
|
| 369 | - |
|
| 370 | - /** |
|
| 371 | - * Set name |
|
| 372 | - * |
|
| 373 | - * @param string $name |
|
| 374 | - * |
|
| 375 | - * @return $this |
|
| 376 | - */ |
|
| 377 | - public function setName($name) |
|
| 378 | - { |
|
| 379 | - $this->name = (string) $name; |
|
| 380 | - |
|
| 381 | - return $this; |
|
| 382 | - } |
|
| 383 | - |
|
| 384 | - /** |
|
| 385 | - * Get see https://www.bayernlb.de/internet/media/de/ir/downloads_1/zahlungsverkehr/formate_1/MT940_942.pdf page 451 / 8.2.6 Geschäftsvorfallcodes |
|
| 386 | - * |
|
| 387 | - * @return string |
|
| 388 | - */ |
|
| 389 | - public function getTransactionCode() |
|
| 390 | - { |
|
| 391 | - return $this->transactionCode; |
|
| 392 | - } |
|
| 393 | - |
|
| 394 | - /** |
|
| 395 | - * Set see https://www.bayernlb.de/internet/media/de/ir/downloads_1/zahlungsverkehr/formate_1/MT940_942.pdf page 451 / 8.2.6 Geschäftsvorfallcodes |
|
| 396 | - * |
|
| 397 | - * @param string $transactionCode See https://www.bayernlb.de/internet/media/de/ir/downloads_1/zahlungsverkehr/formate_1/MT940_942.pdf page 451 / 8.2.6 Geschäftsvorfallcodes |
|
| 398 | - * |
|
| 399 | - * @return self |
|
| 400 | - */ |
|
| 401 | - public function setTransactionCode($transactionCode) |
|
| 402 | - { |
|
| 403 | - $this->transactionCode = $transactionCode; |
|
| 404 | - |
|
| 405 | - return $this; |
|
| 406 | - } |
|
| 11 | + const CD_CREDIT = 'credit'; |
|
| 12 | + const CD_DEBIT = 'debit'; |
|
| 13 | + const CD_CREDIT_CANCELLATION = 'credit_cancellation'; |
|
| 14 | + const CD_DEBIT_CANCELLATION = 'debit_cancellation'; |
|
| 15 | + |
|
| 16 | + /** |
|
| 17 | + * @var \DateTime|null |
|
| 18 | + */ |
|
| 19 | + protected $bookingDate; |
|
| 20 | + |
|
| 21 | + /** |
|
| 22 | + * @var \DateTime|null |
|
| 23 | + */ |
|
| 24 | + protected $valutaDate; |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * @var float |
|
| 28 | + */ |
|
| 29 | + protected $amount; |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * @var string |
|
| 33 | + */ |
|
| 34 | + protected $creditDebit; |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * @var string |
|
| 38 | + */ |
|
| 39 | + protected $bookingText; |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * @var string |
|
| 43 | + */ |
|
| 44 | + protected $description1; |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * @var string |
|
| 48 | + */ |
|
| 49 | + protected $description2; |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * Array keys are identifiers like "SVWZ" for the main description. |
|
| 53 | + * @var string[] |
|
| 54 | + */ |
|
| 55 | + protected $structuredDescription; |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * @var string |
|
| 59 | + */ |
|
| 60 | + protected $bankCode; |
|
| 61 | + |
|
| 62 | + /** |
|
| 63 | + * @var string |
|
| 64 | + */ |
|
| 65 | + protected $accountNumber; |
|
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * @var string |
|
| 69 | + */ |
|
| 70 | + protected $name; |
|
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * See https://www.bayernlb.de/internet/media/de/ir/downloads_1/zahlungsverkehr/formate_1/MT940_942.pdf page 451 / 8.2.6 Geschäftsvorfallcodes |
|
| 74 | + * @var string |
|
| 75 | + */ |
|
| 76 | + protected $transactionCode; |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | + * Get booking date. |
|
| 80 | + * |
|
| 81 | + * @deprecated Use getBookingDate() instead |
|
| 82 | + * @codeCoverageIgnore |
|
| 83 | + * @return \DateTime|null |
|
| 84 | + */ |
|
| 85 | + public function getDate() |
|
| 86 | + { |
|
| 87 | + return $this->getBookingDate(); |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + /** |
|
| 91 | + * Get booking date |
|
| 92 | + * |
|
| 93 | + * @return \DateTime|null |
|
| 94 | + */ |
|
| 95 | + public function getBookingDate() |
|
| 96 | + { |
|
| 97 | + return $this->bookingDate; |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + /** |
|
| 101 | + * Get date |
|
| 102 | + * |
|
| 103 | + * @return \DateTime|null |
|
| 104 | + */ |
|
| 105 | + public function getValutaDate() |
|
| 106 | + { |
|
| 107 | + return $this->valutaDate; |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + /** |
|
| 111 | + * Set booking date |
|
| 112 | + * |
|
| 113 | + * @param \DateTime|null $date |
|
| 114 | + * |
|
| 115 | + * @return $this |
|
| 116 | + */ |
|
| 117 | + public function setBookingDate(\DateTime $date = null) |
|
| 118 | + { |
|
| 119 | + $this->bookingDate = $date; |
|
| 120 | + |
|
| 121 | + return $this; |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + /** |
|
| 125 | + * Set valuta date |
|
| 126 | + * |
|
| 127 | + * @param \DateTime|null $date |
|
| 128 | + * |
|
| 129 | + * @return $this |
|
| 130 | + */ |
|
| 131 | + public function setValutaDate(\DateTime $date = null) |
|
| 132 | + { |
|
| 133 | + $this->valutaDate = $date; |
|
| 134 | + |
|
| 135 | + return $this; |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + /** |
|
| 139 | + * Get the signed amount based on credit/debit setting. |
|
| 140 | + * Debits and canceled credits have a negative sign. |
|
| 141 | + * @return float |
|
| 142 | + */ |
|
| 143 | + public function getSignedAmount() |
|
| 144 | + { |
|
| 145 | + switch ($this->creditDebit) { |
|
| 146 | + case Transaction::CD_DEBIT: |
|
| 147 | + case Transaction::CD_CREDIT_CANCELLATION: |
|
| 148 | + return -1 * $this->amount; |
|
| 149 | + default: |
|
| 150 | + return $this->amount; |
|
| 151 | + } |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + /** |
|
| 155 | + * Get amount |
|
| 156 | + * |
|
| 157 | + * @return float |
|
| 158 | + */ |
|
| 159 | + public function getAmount() |
|
| 160 | + { |
|
| 161 | + return $this->amount; |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + /** |
|
| 165 | + * Set amount |
|
| 166 | + * |
|
| 167 | + * @param float $amount |
|
| 168 | + * |
|
| 169 | + * @return $this |
|
| 170 | + */ |
|
| 171 | + public function setAmount($amount) |
|
| 172 | + { |
|
| 173 | + $this->amount = (float) $amount; |
|
| 174 | + |
|
| 175 | + return $this; |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + /** |
|
| 179 | + * Get creditDebit |
|
| 180 | + * |
|
| 181 | + * @return string |
|
| 182 | + */ |
|
| 183 | + public function getCreditDebit() |
|
| 184 | + { |
|
| 185 | + return $this->creditDebit; |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + /** |
|
| 189 | + * Set creditDebit |
|
| 190 | + * |
|
| 191 | + * @param string $creditDebit |
|
| 192 | + * |
|
| 193 | + * @return $this |
|
| 194 | + */ |
|
| 195 | + public function setCreditDebit($creditDebit) |
|
| 196 | + { |
|
| 197 | + $this->creditDebit = $creditDebit; |
|
| 198 | + |
|
| 199 | + return $this; |
|
| 200 | + } |
|
| 201 | + |
|
| 202 | + /** |
|
| 203 | + * Get bookingText |
|
| 204 | + * |
|
| 205 | + * @return string |
|
| 206 | + */ |
|
| 207 | + public function getBookingText() |
|
| 208 | + { |
|
| 209 | + return $this->bookingText; |
|
| 210 | + } |
|
| 211 | + |
|
| 212 | + /** |
|
| 213 | + * Set bookingText |
|
| 214 | + * |
|
| 215 | + * @param string $bookingText |
|
| 216 | + * |
|
| 217 | + * @return $this |
|
| 218 | + */ |
|
| 219 | + public function setBookingText($bookingText) |
|
| 220 | + { |
|
| 221 | + $this->bookingText = (string) $bookingText; |
|
| 222 | + |
|
| 223 | + return $this; |
|
| 224 | + } |
|
| 225 | + |
|
| 226 | + /** |
|
| 227 | + * Get description1 |
|
| 228 | + * |
|
| 229 | + * @return string |
|
| 230 | + */ |
|
| 231 | + public function getDescription1() |
|
| 232 | + { |
|
| 233 | + return $this->description1; |
|
| 234 | + } |
|
| 235 | + |
|
| 236 | + /** |
|
| 237 | + * Set description1 |
|
| 238 | + * |
|
| 239 | + * @param string $description1 |
|
| 240 | + * |
|
| 241 | + * @return $this |
|
| 242 | + */ |
|
| 243 | + public function setDescription1($description1) |
|
| 244 | + { |
|
| 245 | + $this->description1 = (string) $description1; |
|
| 246 | + |
|
| 247 | + return $this; |
|
| 248 | + } |
|
| 249 | + |
|
| 250 | + /** |
|
| 251 | + * Get description2 |
|
| 252 | + * |
|
| 253 | + * @return string |
|
| 254 | + */ |
|
| 255 | + public function getDescription2() |
|
| 256 | + { |
|
| 257 | + return $this->description2; |
|
| 258 | + } |
|
| 259 | + |
|
| 260 | + /** |
|
| 261 | + * Set description2 |
|
| 262 | + * |
|
| 263 | + * @param string $description2 |
|
| 264 | + * |
|
| 265 | + * @return $this |
|
| 266 | + */ |
|
| 267 | + public function setDescription2($description2) |
|
| 268 | + { |
|
| 269 | + $this->description2 = (string) $description2; |
|
| 270 | + |
|
| 271 | + return $this; |
|
| 272 | + } |
|
| 273 | + |
|
| 274 | + /** |
|
| 275 | + * Get structuredDescription |
|
| 276 | + * |
|
| 277 | + * @return string[] |
|
| 278 | + */ |
|
| 279 | + public function getStructuredDescription() |
|
| 280 | + { |
|
| 281 | + return $this->structuredDescription; |
|
| 282 | + } |
|
| 283 | + |
|
| 284 | + /** |
|
| 285 | + * Set structuredDescription |
|
| 286 | + * |
|
| 287 | + * @param string[] $structuredDescription |
|
| 288 | + * |
|
| 289 | + * @return $this |
|
| 290 | + */ |
|
| 291 | + public function setStructuredDescription($structuredDescription) |
|
| 292 | + { |
|
| 293 | + $this->structuredDescription = $structuredDescription; |
|
| 294 | + |
|
| 295 | + return $this; |
|
| 296 | + } |
|
| 297 | + |
|
| 298 | + /** |
|
| 299 | + * Get the main description (SVWZ) |
|
| 300 | + * |
|
| 301 | + * @return string |
|
| 302 | + */ |
|
| 303 | + public function getMainDescription() |
|
| 304 | + { |
|
| 305 | + if (array_key_exists('SVWZ', $this->structuredDescription)) { |
|
| 306 | + return $this->structuredDescription['SVWZ']; |
|
| 307 | + } else { |
|
| 308 | + return ''; |
|
| 309 | + } |
|
| 310 | + } |
|
| 311 | + |
|
| 312 | + /** |
|
| 313 | + * Get bankCode |
|
| 314 | + * |
|
| 315 | + * @return string |
|
| 316 | + */ |
|
| 317 | + public function getBankCode() |
|
| 318 | + { |
|
| 319 | + return $this->bankCode; |
|
| 320 | + } |
|
| 321 | + |
|
| 322 | + /** |
|
| 323 | + * Set bankCode |
|
| 324 | + * |
|
| 325 | + * @param string $bankCode |
|
| 326 | + * |
|
| 327 | + * @return $this |
|
| 328 | + */ |
|
| 329 | + public function setBankCode($bankCode) |
|
| 330 | + { |
|
| 331 | + $this->bankCode = (string) $bankCode; |
|
| 332 | + |
|
| 333 | + return $this; |
|
| 334 | + } |
|
| 335 | + |
|
| 336 | + /** |
|
| 337 | + * Get accountNumber |
|
| 338 | + * |
|
| 339 | + * @return string |
|
| 340 | + */ |
|
| 341 | + public function getAccountNumber() |
|
| 342 | + { |
|
| 343 | + return $this->accountNumber; |
|
| 344 | + } |
|
| 345 | + |
|
| 346 | + /** |
|
| 347 | + * Set accountNumber |
|
| 348 | + * |
|
| 349 | + * @param string $accountNumber |
|
| 350 | + * |
|
| 351 | + * @return $this |
|
| 352 | + */ |
|
| 353 | + public function setAccountNumber($accountNumber) |
|
| 354 | + { |
|
| 355 | + $this->accountNumber = (string) $accountNumber; |
|
| 356 | + |
|
| 357 | + return $this; |
|
| 358 | + } |
|
| 359 | + |
|
| 360 | + /** |
|
| 361 | + * Get name |
|
| 362 | + * |
|
| 363 | + * @return string |
|
| 364 | + */ |
|
| 365 | + public function getName() |
|
| 366 | + { |
|
| 367 | + return $this->name; |
|
| 368 | + } |
|
| 369 | + |
|
| 370 | + /** |
|
| 371 | + * Set name |
|
| 372 | + * |
|
| 373 | + * @param string $name |
|
| 374 | + * |
|
| 375 | + * @return $this |
|
| 376 | + */ |
|
| 377 | + public function setName($name) |
|
| 378 | + { |
|
| 379 | + $this->name = (string) $name; |
|
| 380 | + |
|
| 381 | + return $this; |
|
| 382 | + } |
|
| 383 | + |
|
| 384 | + /** |
|
| 385 | + * Get see https://www.bayernlb.de/internet/media/de/ir/downloads_1/zahlungsverkehr/formate_1/MT940_942.pdf page 451 / 8.2.6 Geschäftsvorfallcodes |
|
| 386 | + * |
|
| 387 | + * @return string |
|
| 388 | + */ |
|
| 389 | + public function getTransactionCode() |
|
| 390 | + { |
|
| 391 | + return $this->transactionCode; |
|
| 392 | + } |
|
| 393 | + |
|
| 394 | + /** |
|
| 395 | + * Set see https://www.bayernlb.de/internet/media/de/ir/downloads_1/zahlungsverkehr/formate_1/MT940_942.pdf page 451 / 8.2.6 Geschäftsvorfallcodes |
|
| 396 | + * |
|
| 397 | + * @param string $transactionCode See https://www.bayernlb.de/internet/media/de/ir/downloads_1/zahlungsverkehr/formate_1/MT940_942.pdf page 451 / 8.2.6 Geschäftsvorfallcodes |
|
| 398 | + * |
|
| 399 | + * @return self |
|
| 400 | + */ |
|
| 401 | + public function setTransactionCode($transactionCode) |
|
| 402 | + { |
|
| 403 | + $this->transactionCode = $transactionCode; |
|
| 404 | + |
|
| 405 | + return $this; |
|
| 406 | + } |
|
| 407 | 407 | } |
@@ -8,136 +8,136 @@ |
||
| 8 | 8 | */ |
| 9 | 9 | class Statement |
| 10 | 10 | { |
| 11 | - const CD_CREDIT = 'credit'; |
|
| 12 | - const CD_DEBIT = 'debit'; |
|
| 13 | - |
|
| 14 | - /** |
|
| 15 | - * @var array of Transaction |
|
| 16 | - */ |
|
| 17 | - protected $transactions = array(); |
|
| 18 | - |
|
| 19 | - /** |
|
| 20 | - * @var float |
|
| 21 | - */ |
|
| 22 | - protected $startBalance = 0.0; |
|
| 23 | - |
|
| 24 | - /** |
|
| 25 | - * @var string |
|
| 26 | - */ |
|
| 27 | - protected $creditDebit; |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * @var \DateTime|null |
|
| 31 | - */ |
|
| 32 | - protected $date; |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * Get transactions |
|
| 36 | - * |
|
| 37 | - * @return Transaction[] |
|
| 38 | - */ |
|
| 39 | - public function getTransactions() |
|
| 40 | - { |
|
| 41 | - return $this->transactions; |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * Set transactions |
|
| 46 | - * |
|
| 47 | - * @param array $transactions |
|
| 48 | - * |
|
| 49 | - * @return $this |
|
| 50 | - */ |
|
| 51 | - public function setTransactions(array $transactions = null) |
|
| 52 | - { |
|
| 53 | - $this->transactions = $transactions; |
|
| 54 | - |
|
| 55 | - return $this; |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - public function addTransaction(Transaction $transaction) |
|
| 59 | - { |
|
| 60 | - $this->transactions[] = $transaction; |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * Get startBalance |
|
| 65 | - * |
|
| 66 | - * @return float |
|
| 67 | - */ |
|
| 68 | - public function getStartBalance() |
|
| 69 | - { |
|
| 70 | - return $this->startBalance; |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - public function getSignedStartBalance() |
|
| 74 | - { |
|
| 75 | - $s = 1; |
|
| 76 | - if ($this->getCreditDebit() == self::CD_DEBIT) { |
|
| 77 | - $s = -1; |
|
| 78 | - } |
|
| 79 | - return $s * $this->getStartBalance(); |
|
| 80 | - } |
|
| 81 | - |
|
| 82 | - /** |
|
| 83 | - * Set startBalance |
|
| 84 | - * |
|
| 85 | - * @param float $startBalance |
|
| 86 | - * |
|
| 87 | - * @return $this |
|
| 88 | - */ |
|
| 89 | - public function setStartBalance($startBalance) |
|
| 90 | - { |
|
| 91 | - $this->startBalance = (float) $startBalance; |
|
| 92 | - |
|
| 93 | - return $this; |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - /** |
|
| 97 | - * Get creditDebit |
|
| 98 | - * |
|
| 99 | - * @return string |
|
| 100 | - */ |
|
| 101 | - public function getCreditDebit() |
|
| 102 | - { |
|
| 103 | - return $this->creditDebit; |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - /** |
|
| 107 | - * Set creditDebit |
|
| 108 | - * |
|
| 109 | - * @param string|null $creditDebit |
|
| 110 | - * |
|
| 111 | - * @return $this |
|
| 112 | - */ |
|
| 113 | - public function setCreditDebit($creditDebit) |
|
| 114 | - { |
|
| 115 | - $this->creditDebit = $creditDebit; |
|
| 116 | - |
|
| 117 | - return $this; |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - /** |
|
| 121 | - * Get date |
|
| 122 | - * |
|
| 123 | - * @return \DateTime |
|
| 124 | - */ |
|
| 125 | - public function getDate() |
|
| 126 | - { |
|
| 127 | - return $this->date; |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - /** |
|
| 131 | - * Set date |
|
| 132 | - * |
|
| 133 | - * @param \DateTime $date |
|
| 134 | - * |
|
| 135 | - * @return $this |
|
| 136 | - */ |
|
| 137 | - public function setDate(\DateTime $date) |
|
| 138 | - { |
|
| 139 | - $this->date = $date; |
|
| 140 | - |
|
| 141 | - return $this; |
|
| 142 | - } |
|
| 11 | + const CD_CREDIT = 'credit'; |
|
| 12 | + const CD_DEBIT = 'debit'; |
|
| 13 | + |
|
| 14 | + /** |
|
| 15 | + * @var array of Transaction |
|
| 16 | + */ |
|
| 17 | + protected $transactions = array(); |
|
| 18 | + |
|
| 19 | + /** |
|
| 20 | + * @var float |
|
| 21 | + */ |
|
| 22 | + protected $startBalance = 0.0; |
|
| 23 | + |
|
| 24 | + /** |
|
| 25 | + * @var string |
|
| 26 | + */ |
|
| 27 | + protected $creditDebit; |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * @var \DateTime|null |
|
| 31 | + */ |
|
| 32 | + protected $date; |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * Get transactions |
|
| 36 | + * |
|
| 37 | + * @return Transaction[] |
|
| 38 | + */ |
|
| 39 | + public function getTransactions() |
|
| 40 | + { |
|
| 41 | + return $this->transactions; |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * Set transactions |
|
| 46 | + * |
|
| 47 | + * @param array $transactions |
|
| 48 | + * |
|
| 49 | + * @return $this |
|
| 50 | + */ |
|
| 51 | + public function setTransactions(array $transactions = null) |
|
| 52 | + { |
|
| 53 | + $this->transactions = $transactions; |
|
| 54 | + |
|
| 55 | + return $this; |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + public function addTransaction(Transaction $transaction) |
|
| 59 | + { |
|
| 60 | + $this->transactions[] = $transaction; |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * Get startBalance |
|
| 65 | + * |
|
| 66 | + * @return float |
|
| 67 | + */ |
|
| 68 | + public function getStartBalance() |
|
| 69 | + { |
|
| 70 | + return $this->startBalance; |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + public function getSignedStartBalance() |
|
| 74 | + { |
|
| 75 | + $s = 1; |
|
| 76 | + if ($this->getCreditDebit() == self::CD_DEBIT) { |
|
| 77 | + $s = -1; |
|
| 78 | + } |
|
| 79 | + return $s * $this->getStartBalance(); |
|
| 80 | + } |
|
| 81 | + |
|
| 82 | + /** |
|
| 83 | + * Set startBalance |
|
| 84 | + * |
|
| 85 | + * @param float $startBalance |
|
| 86 | + * |
|
| 87 | + * @return $this |
|
| 88 | + */ |
|
| 89 | + public function setStartBalance($startBalance) |
|
| 90 | + { |
|
| 91 | + $this->startBalance = (float) $startBalance; |
|
| 92 | + |
|
| 93 | + return $this; |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + /** |
|
| 97 | + * Get creditDebit |
|
| 98 | + * |
|
| 99 | + * @return string |
|
| 100 | + */ |
|
| 101 | + public function getCreditDebit() |
|
| 102 | + { |
|
| 103 | + return $this->creditDebit; |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + /** |
|
| 107 | + * Set creditDebit |
|
| 108 | + * |
|
| 109 | + * @param string|null $creditDebit |
|
| 110 | + * |
|
| 111 | + * @return $this |
|
| 112 | + */ |
|
| 113 | + public function setCreditDebit($creditDebit) |
|
| 114 | + { |
|
| 115 | + $this->creditDebit = $creditDebit; |
|
| 116 | + |
|
| 117 | + return $this; |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + /** |
|
| 121 | + * Get date |
|
| 122 | + * |
|
| 123 | + * @return \DateTime |
|
| 124 | + */ |
|
| 125 | + public function getDate() |
|
| 126 | + { |
|
| 127 | + return $this->date; |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + /** |
|
| 131 | + * Set date |
|
| 132 | + * |
|
| 133 | + * @param \DateTime $date |
|
| 134 | + * |
|
| 135 | + * @return $this |
|
| 136 | + */ |
|
| 137 | + public function setDate(\DateTime $date) |
|
| 138 | + { |
|
| 139 | + $this->date = $date; |
|
| 140 | + |
|
| 141 | + return $this; |
|
| 142 | + } |
|
| 143 | 143 | } |
@@ -10,235 +10,235 @@ |
||
| 10 | 10 | */ |
| 11 | 11 | class MT940 |
| 12 | 12 | { |
| 13 | - const TARGET_ARRAY = 0; |
|
| 14 | - |
|
| 15 | - const CD_CREDIT = 'credit'; |
|
| 16 | - const CD_DEBIT = 'debit'; |
|
| 17 | - const CD_CREDIT_CANCELLATION = 'credit_cancellation'; |
|
| 18 | - const CD_DEBIT_CANCELLATION = 'debit_cancellation'; |
|
| 19 | - |
|
| 20 | - /** @var string */ |
|
| 21 | - protected $rawData; |
|
| 22 | - /** @var string */ |
|
| 23 | - protected $soaDate; |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * MT940 constructor. |
|
| 27 | - * |
|
| 28 | - * @param string $rawData |
|
| 29 | - */ |
|
| 30 | - public function __construct($rawData) |
|
| 31 | - { |
|
| 32 | - $this->rawData = (string) $rawData; |
|
| 33 | - } |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * @param string $target |
|
| 37 | - * @return array |
|
| 38 | - * @throws MT940Exception |
|
| 39 | - */ |
|
| 40 | - public function parse($target) |
|
| 41 | - { |
|
| 42 | - switch ($target) { |
|
| 43 | - case static::TARGET_ARRAY: |
|
| 44 | - return $this->parseToArray(); |
|
| 45 | - break; |
|
| 46 | - default: |
|
| 47 | - throw new MT940Exception('Invalid parse type provided'); |
|
| 48 | - } |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * @return array |
|
| 53 | - * @throws MT940Exception |
|
| 54 | - */ |
|
| 55 | - protected function parseToArray() |
|
| 56 | - { |
|
| 57 | - // The divider can be either \r\n or @@ |
|
| 58 | - |
|
| 59 | - $divider = "(@@|\r\n)"; |
|
| 60 | - $result = array(); |
|
| 61 | - $days = preg_split('/' . $divider . '-' . $divider . '/', $this->rawData); |
|
| 62 | - |
|
| 63 | - foreach ($days as $day) { |
|
| 64 | - $day = preg_split('/' . $divider . ':/', $day); |
|
| 65 | - $statement = array(); |
|
| 66 | - $transactions = array(); |
|
| 67 | - $cnt = 0; |
|
| 68 | - for ($i = 0, $cnt = count($day); $i < $cnt; $i++) { |
|
| 69 | - // handle start balance |
|
| 70 | - // 60F:C160401EUR1234,56 |
|
| 71 | - if (preg_match('/^60(F|M):/', $day[$i])) { |
|
| 72 | - // remove 60(F|M): for better parsing |
|
| 73 | - $day[$i] = substr($day[$i], 4); |
|
| 74 | - $this->soaDate = $this->getDate(substr($day[$i], 1, 6)); |
|
| 75 | - |
|
| 76 | - $amount = str_replace(',', '.', substr($day[$i], 10)); |
|
| 77 | - $statement['start_balance'] = array( |
|
| 78 | - 'amount' => $amount, |
|
| 79 | - 'credit_debit' => (substr($day[$i], 0, 1) == 'C') ? static::CD_CREDIT : static::CD_DEBIT |
|
| 80 | - ); |
|
| 81 | - $statement['date'] = $this->soaDate; |
|
| 82 | - } elseif ( |
|
| 83 | - // found transaction |
|
| 84 | - // trx:61:1603310331DR637,39N033NONREF |
|
| 85 | - 0 === strpos($day[$i], '61:') |
|
| 86 | - && isset($day[$i + 1]) |
|
| 87 | - && 0 === strpos($day[$i + 1], '86:') |
|
| 88 | - ) { |
|
| 89 | - $transaction = substr($day[$i], 3); |
|
| 90 | - $description = substr($day[$i + 1], 3); |
|
| 91 | - |
|
| 92 | - $currentTrx = array(); |
|
| 93 | - |
|
| 94 | - preg_match('/^\d{6}(\d{4})?(C|D|RC|RD)[A-Z]?([^N]+)N/', $transaction, $matches); |
|
| 95 | - |
|
| 96 | - switch ($matches[2]) { |
|
| 97 | - case 'C': |
|
| 98 | - $currentTrx['credit_debit'] = static::CD_CREDIT; |
|
| 99 | - break; |
|
| 100 | - case 'D': |
|
| 101 | - $currentTrx['credit_debit'] = static::CD_DEBIT; |
|
| 102 | - break; |
|
| 103 | - case 'RC': |
|
| 104 | - $currentTrx['credit_debit'] = static::CD_CREDIT_CANCELLATION; |
|
| 105 | - break; |
|
| 106 | - case 'RD': |
|
| 107 | - $currentTrx['credit_debit'] = static::CD_DEBIT_CANCELLATION; |
|
| 108 | - break; |
|
| 109 | - default: |
|
| 110 | - throw new MT940Exception('c/d/rc/rd mark not found in: ' . $transaction); |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - $amount = $matches[3]; |
|
| 114 | - $amount = str_replace(',', '.', $amount); |
|
| 115 | - $currentTrx['amount'] = floatval($amount); |
|
| 116 | - |
|
| 117 | - $currentTrx['transaction_code'] = substr($description, 0, 3); |
|
| 118 | - |
|
| 119 | - $description = $this->parseDescription($description); |
|
| 120 | - $currentTrx['description'] = $description; |
|
| 121 | - |
|
| 122 | - // :61:1605110509D198,02NMSCNONREF |
|
| 123 | - // 16 = year |
|
| 124 | - // 0511 = valuta date |
|
| 125 | - // 0509 = booking date |
|
| 126 | - $year = substr($transaction, 0, 2); |
|
| 127 | - $valutaDate = $this->getDate($year . substr($transaction, 2, 4)); |
|
| 128 | - |
|
| 129 | - $bookingDate = substr($transaction, 6, 4); |
|
| 130 | - if (preg_match('/^\d{4}$/', $bookingDate)) { |
|
| 131 | - // if valuta date is earlier than booking date, then it must be in the new year. |
|
| 132 | - if (substr($transaction, 2, 2) == '12' && substr($transaction, 6, 2) == '01') { |
|
| 133 | - $year++; |
|
| 134 | - } elseif (substr($transaction, 2, 2) == '01' && substr($transaction, 6, 2) == '12') { |
|
| 135 | - $year--; |
|
| 136 | - } |
|
| 137 | - $bookingDate = $this->getDate($year . $bookingDate); |
|
| 138 | - } else { |
|
| 139 | - // if booking date not set in :61, then we have to take it from :60F |
|
| 140 | - $bookingDate = $this->soaDate; |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - $currentTrx['booking_date'] = $bookingDate; |
|
| 144 | - $currentTrx['valuta_date'] = $valutaDate; |
|
| 145 | - |
|
| 146 | - $transactions[] = $currentTrx; |
|
| 147 | - } |
|
| 148 | - } |
|
| 149 | - $statement['transactions'] = $transactions; |
|
| 150 | - if (count($transactions) > 0) { |
|
| 151 | - $result[] = $statement; |
|
| 152 | - } |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - return $result; |
|
| 156 | - } |
|
| 157 | - |
|
| 158 | - /** |
|
| 159 | - * @param string $descr |
|
| 160 | - * @return array |
|
| 161 | - */ |
|
| 162 | - protected function parseDescription($descr) |
|
| 163 | - { |
|
| 164 | - $prepared = array(); |
|
| 165 | - $result = array(); |
|
| 166 | - |
|
| 167 | - // prefill with empty values |
|
| 168 | - for ($i = 0; $i <= 63; $i++) { |
|
| 169 | - $prepared[$i] = null; |
|
| 170 | - } |
|
| 171 | - |
|
| 172 | - $descr = str_replace("\r\n", '', $descr); |
|
| 173 | - $descr = str_replace('? ', '?', $descr); |
|
| 174 | - preg_match_all('/\?[\r\n]*(\d{2})([^\?]+)/', $descr, $matches, PREG_SET_ORDER); |
|
| 175 | - |
|
| 176 | - $descriptionLines = array(); |
|
| 177 | - $description1 = ''; // Legacy, could be removed. |
|
| 178 | - $description2 = ''; // Legacy, could be removed. |
|
| 179 | - foreach ($matches as $m) { |
|
| 180 | - $index = (int) $m[1]; |
|
| 181 | - if ((20 <= $index && $index <= 29) || (60 <= $index && $index <= 63)) { |
|
| 182 | - if (20 <= $index && $index <= 29) { |
|
| 183 | - $description1 .= $m[2]; |
|
| 184 | - } else { |
|
| 185 | - $description2 .= $m[2]; |
|
| 186 | - } |
|
| 187 | - $m[2] = trim($m[2]); |
|
| 188 | - if (!empty($m[2])) { |
|
| 189 | - $descriptionLines[] = $m[2]; |
|
| 190 | - } |
|
| 191 | - } else { |
|
| 192 | - $prepared[$index] = $m[2]; |
|
| 193 | - } |
|
| 194 | - } |
|
| 195 | - |
|
| 196 | - $description = array(); |
|
| 197 | - if (empty($descriptionLines) || strlen($descriptionLines[0]) < 5 || $descriptionLines[0][4] !== '+') { |
|
| 198 | - $description['SVWZ'] = implode('', $descriptionLines); |
|
| 199 | - } else { |
|
| 200 | - $lastType = null; |
|
| 201 | - foreach ($descriptionLines as $line) { |
|
| 202 | - if (strlen($line) > 5 && $line[4] === '+') { |
|
| 203 | - if ($lastType != null) { |
|
| 204 | - $description[$lastType] = trim($description[$lastType]); |
|
| 205 | - } |
|
| 206 | - $lastType = substr($line, 0, 4); |
|
| 207 | - $description[$lastType] = substr($line, 5); |
|
| 208 | - } else { |
|
| 209 | - $description[$lastType] .= $line; |
|
| 210 | - } |
|
| 211 | - if (strlen($line) < 27) { |
|
| 212 | - // Usually, lines are 27 characters long. In case characters are missing, then it's either the end |
|
| 213 | - // of the current type or spaces have been trimmed from the end. We want to collapse multiple spaces |
|
| 214 | - // into one and we don't want to leave trailing spaces behind. So add a single space here to make up |
|
| 215 | - // for possibly missing spaces, and if it's the end of the type, it will be trimmed off later. |
|
| 216 | - $description[$lastType] .= ' '; |
|
| 217 | - } |
|
| 218 | - } |
|
| 219 | - $description[$lastType] = trim($description[$lastType]); |
|
| 220 | - } |
|
| 221 | - |
|
| 222 | - $result['description'] = $description; |
|
| 223 | - $result['booking_text'] = trim($prepared[0]); |
|
| 224 | - $result['primanoten_nr'] = trim($prepared[10]); |
|
| 225 | - $result['description_1'] = trim($description1); |
|
| 226 | - $result['bank_code'] = trim($prepared[30]); |
|
| 227 | - $result['account_number'] = trim($prepared[31]); |
|
| 228 | - $result['name'] = trim($prepared[32] . $prepared[33]); |
|
| 229 | - $result['text_key_addition'] = trim($prepared[34]); |
|
| 230 | - $result['description_2'] = trim($description2); |
|
| 231 | - return $result; |
|
| 232 | - } |
|
| 233 | - |
|
| 234 | - /** |
|
| 235 | - * @param string $val |
|
| 236 | - * @return string |
|
| 237 | - */ |
|
| 238 | - protected function getDate($val) |
|
| 239 | - { |
|
| 240 | - $val = '20' . $val; |
|
| 241 | - preg_match('/(\d{4})(\d{2})(\d{2})/', $val, $m); |
|
| 242 | - return $m[1] . '-' . $m[2] . '-' . $m[3]; |
|
| 243 | - } |
|
| 13 | + const TARGET_ARRAY = 0; |
|
| 14 | + |
|
| 15 | + const CD_CREDIT = 'credit'; |
|
| 16 | + const CD_DEBIT = 'debit'; |
|
| 17 | + const CD_CREDIT_CANCELLATION = 'credit_cancellation'; |
|
| 18 | + const CD_DEBIT_CANCELLATION = 'debit_cancellation'; |
|
| 19 | + |
|
| 20 | + /** @var string */ |
|
| 21 | + protected $rawData; |
|
| 22 | + /** @var string */ |
|
| 23 | + protected $soaDate; |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * MT940 constructor. |
|
| 27 | + * |
|
| 28 | + * @param string $rawData |
|
| 29 | + */ |
|
| 30 | + public function __construct($rawData) |
|
| 31 | + { |
|
| 32 | + $this->rawData = (string) $rawData; |
|
| 33 | + } |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * @param string $target |
|
| 37 | + * @return array |
|
| 38 | + * @throws MT940Exception |
|
| 39 | + */ |
|
| 40 | + public function parse($target) |
|
| 41 | + { |
|
| 42 | + switch ($target) { |
|
| 43 | + case static::TARGET_ARRAY: |
|
| 44 | + return $this->parseToArray(); |
|
| 45 | + break; |
|
| 46 | + default: |
|
| 47 | + throw new MT940Exception('Invalid parse type provided'); |
|
| 48 | + } |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * @return array |
|
| 53 | + * @throws MT940Exception |
|
| 54 | + */ |
|
| 55 | + protected function parseToArray() |
|
| 56 | + { |
|
| 57 | + // The divider can be either \r\n or @@ |
|
| 58 | + |
|
| 59 | + $divider = "(@@|\r\n)"; |
|
| 60 | + $result = array(); |
|
| 61 | + $days = preg_split('/' . $divider . '-' . $divider . '/', $this->rawData); |
|
| 62 | + |
|
| 63 | + foreach ($days as $day) { |
|
| 64 | + $day = preg_split('/' . $divider . ':/', $day); |
|
| 65 | + $statement = array(); |
|
| 66 | + $transactions = array(); |
|
| 67 | + $cnt = 0; |
|
| 68 | + for ($i = 0, $cnt = count($day); $i < $cnt; $i++) { |
|
| 69 | + // handle start balance |
|
| 70 | + // 60F:C160401EUR1234,56 |
|
| 71 | + if (preg_match('/^60(F|M):/', $day[$i])) { |
|
| 72 | + // remove 60(F|M): for better parsing |
|
| 73 | + $day[$i] = substr($day[$i], 4); |
|
| 74 | + $this->soaDate = $this->getDate(substr($day[$i], 1, 6)); |
|
| 75 | + |
|
| 76 | + $amount = str_replace(',', '.', substr($day[$i], 10)); |
|
| 77 | + $statement['start_balance'] = array( |
|
| 78 | + 'amount' => $amount, |
|
| 79 | + 'credit_debit' => (substr($day[$i], 0, 1) == 'C') ? static::CD_CREDIT : static::CD_DEBIT |
|
| 80 | + ); |
|
| 81 | + $statement['date'] = $this->soaDate; |
|
| 82 | + } elseif ( |
|
| 83 | + // found transaction |
|
| 84 | + // trx:61:1603310331DR637,39N033NONREF |
|
| 85 | + 0 === strpos($day[$i], '61:') |
|
| 86 | + && isset($day[$i + 1]) |
|
| 87 | + && 0 === strpos($day[$i + 1], '86:') |
|
| 88 | + ) { |
|
| 89 | + $transaction = substr($day[$i], 3); |
|
| 90 | + $description = substr($day[$i + 1], 3); |
|
| 91 | + |
|
| 92 | + $currentTrx = array(); |
|
| 93 | + |
|
| 94 | + preg_match('/^\d{6}(\d{4})?(C|D|RC|RD)[A-Z]?([^N]+)N/', $transaction, $matches); |
|
| 95 | + |
|
| 96 | + switch ($matches[2]) { |
|
| 97 | + case 'C': |
|
| 98 | + $currentTrx['credit_debit'] = static::CD_CREDIT; |
|
| 99 | + break; |
|
| 100 | + case 'D': |
|
| 101 | + $currentTrx['credit_debit'] = static::CD_DEBIT; |
|
| 102 | + break; |
|
| 103 | + case 'RC': |
|
| 104 | + $currentTrx['credit_debit'] = static::CD_CREDIT_CANCELLATION; |
|
| 105 | + break; |
|
| 106 | + case 'RD': |
|
| 107 | + $currentTrx['credit_debit'] = static::CD_DEBIT_CANCELLATION; |
|
| 108 | + break; |
|
| 109 | + default: |
|
| 110 | + throw new MT940Exception('c/d/rc/rd mark not found in: ' . $transaction); |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + $amount = $matches[3]; |
|
| 114 | + $amount = str_replace(',', '.', $amount); |
|
| 115 | + $currentTrx['amount'] = floatval($amount); |
|
| 116 | + |
|
| 117 | + $currentTrx['transaction_code'] = substr($description, 0, 3); |
|
| 118 | + |
|
| 119 | + $description = $this->parseDescription($description); |
|
| 120 | + $currentTrx['description'] = $description; |
|
| 121 | + |
|
| 122 | + // :61:1605110509D198,02NMSCNONREF |
|
| 123 | + // 16 = year |
|
| 124 | + // 0511 = valuta date |
|
| 125 | + // 0509 = booking date |
|
| 126 | + $year = substr($transaction, 0, 2); |
|
| 127 | + $valutaDate = $this->getDate($year . substr($transaction, 2, 4)); |
|
| 128 | + |
|
| 129 | + $bookingDate = substr($transaction, 6, 4); |
|
| 130 | + if (preg_match('/^\d{4}$/', $bookingDate)) { |
|
| 131 | + // if valuta date is earlier than booking date, then it must be in the new year. |
|
| 132 | + if (substr($transaction, 2, 2) == '12' && substr($transaction, 6, 2) == '01') { |
|
| 133 | + $year++; |
|
| 134 | + } elseif (substr($transaction, 2, 2) == '01' && substr($transaction, 6, 2) == '12') { |
|
| 135 | + $year--; |
|
| 136 | + } |
|
| 137 | + $bookingDate = $this->getDate($year . $bookingDate); |
|
| 138 | + } else { |
|
| 139 | + // if booking date not set in :61, then we have to take it from :60F |
|
| 140 | + $bookingDate = $this->soaDate; |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + $currentTrx['booking_date'] = $bookingDate; |
|
| 144 | + $currentTrx['valuta_date'] = $valutaDate; |
|
| 145 | + |
|
| 146 | + $transactions[] = $currentTrx; |
|
| 147 | + } |
|
| 148 | + } |
|
| 149 | + $statement['transactions'] = $transactions; |
|
| 150 | + if (count($transactions) > 0) { |
|
| 151 | + $result[] = $statement; |
|
| 152 | + } |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + return $result; |
|
| 156 | + } |
|
| 157 | + |
|
| 158 | + /** |
|
| 159 | + * @param string $descr |
|
| 160 | + * @return array |
|
| 161 | + */ |
|
| 162 | + protected function parseDescription($descr) |
|
| 163 | + { |
|
| 164 | + $prepared = array(); |
|
| 165 | + $result = array(); |
|
| 166 | + |
|
| 167 | + // prefill with empty values |
|
| 168 | + for ($i = 0; $i <= 63; $i++) { |
|
| 169 | + $prepared[$i] = null; |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + $descr = str_replace("\r\n", '', $descr); |
|
| 173 | + $descr = str_replace('? ', '?', $descr); |
|
| 174 | + preg_match_all('/\?[\r\n]*(\d{2})([^\?]+)/', $descr, $matches, PREG_SET_ORDER); |
|
| 175 | + |
|
| 176 | + $descriptionLines = array(); |
|
| 177 | + $description1 = ''; // Legacy, could be removed. |
|
| 178 | + $description2 = ''; // Legacy, could be removed. |
|
| 179 | + foreach ($matches as $m) { |
|
| 180 | + $index = (int) $m[1]; |
|
| 181 | + if ((20 <= $index && $index <= 29) || (60 <= $index && $index <= 63)) { |
|
| 182 | + if (20 <= $index && $index <= 29) { |
|
| 183 | + $description1 .= $m[2]; |
|
| 184 | + } else { |
|
| 185 | + $description2 .= $m[2]; |
|
| 186 | + } |
|
| 187 | + $m[2] = trim($m[2]); |
|
| 188 | + if (!empty($m[2])) { |
|
| 189 | + $descriptionLines[] = $m[2]; |
|
| 190 | + } |
|
| 191 | + } else { |
|
| 192 | + $prepared[$index] = $m[2]; |
|
| 193 | + } |
|
| 194 | + } |
|
| 195 | + |
|
| 196 | + $description = array(); |
|
| 197 | + if (empty($descriptionLines) || strlen($descriptionLines[0]) < 5 || $descriptionLines[0][4] !== '+') { |
|
| 198 | + $description['SVWZ'] = implode('', $descriptionLines); |
|
| 199 | + } else { |
|
| 200 | + $lastType = null; |
|
| 201 | + foreach ($descriptionLines as $line) { |
|
| 202 | + if (strlen($line) > 5 && $line[4] === '+') { |
|
| 203 | + if ($lastType != null) { |
|
| 204 | + $description[$lastType] = trim($description[$lastType]); |
|
| 205 | + } |
|
| 206 | + $lastType = substr($line, 0, 4); |
|
| 207 | + $description[$lastType] = substr($line, 5); |
|
| 208 | + } else { |
|
| 209 | + $description[$lastType] .= $line; |
|
| 210 | + } |
|
| 211 | + if (strlen($line) < 27) { |
|
| 212 | + // Usually, lines are 27 characters long. In case characters are missing, then it's either the end |
|
| 213 | + // of the current type or spaces have been trimmed from the end. We want to collapse multiple spaces |
|
| 214 | + // into one and we don't want to leave trailing spaces behind. So add a single space here to make up |
|
| 215 | + // for possibly missing spaces, and if it's the end of the type, it will be trimmed off later. |
|
| 216 | + $description[$lastType] .= ' '; |
|
| 217 | + } |
|
| 218 | + } |
|
| 219 | + $description[$lastType] = trim($description[$lastType]); |
|
| 220 | + } |
|
| 221 | + |
|
| 222 | + $result['description'] = $description; |
|
| 223 | + $result['booking_text'] = trim($prepared[0]); |
|
| 224 | + $result['primanoten_nr'] = trim($prepared[10]); |
|
| 225 | + $result['description_1'] = trim($description1); |
|
| 226 | + $result['bank_code'] = trim($prepared[30]); |
|
| 227 | + $result['account_number'] = trim($prepared[31]); |
|
| 228 | + $result['name'] = trim($prepared[32] . $prepared[33]); |
|
| 229 | + $result['text_key_addition'] = trim($prepared[34]); |
|
| 230 | + $result['description_2'] = trim($description2); |
|
| 231 | + return $result; |
|
| 232 | + } |
|
| 233 | + |
|
| 234 | + /** |
|
| 235 | + * @param string $val |
|
| 236 | + * @return string |
|
| 237 | + */ |
|
| 238 | + protected function getDate($val) |
|
| 239 | + { |
|
| 240 | + $val = '20' . $val; |
|
| 241 | + preg_match('/(\d{4})(\d{2})(\d{2})/', $val, $m); |
|
| 242 | + return $m[1] . '-' . $m[2] . '-' . $m[3]; |
|
| 243 | + } |
|
| 244 | 244 | } |
@@ -40,11 +40,11 @@ discard block |
||
| 40 | 40 | public function parse($target) |
| 41 | 41 | { |
| 42 | 42 | switch ($target) { |
| 43 | - case static::TARGET_ARRAY: |
|
| 44 | - return $this->parseToArray(); |
|
| 45 | - break; |
|
| 46 | - default: |
|
| 47 | - throw new MT940Exception('Invalid parse type provided'); |
|
| 43 | + case static::TARGET_ARRAY: |
|
| 44 | + return $this->parseToArray(); |
|
| 45 | + break; |
|
| 46 | + default: |
|
| 47 | + throw new MT940Exception('Invalid parse type provided'); |
|
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | |
@@ -94,20 +94,20 @@ discard block |
||
| 94 | 94 | preg_match('/^\d{6}(\d{4})?(C|D|RC|RD)[A-Z]?([^N]+)N/', $transaction, $matches); |
| 95 | 95 | |
| 96 | 96 | switch ($matches[2]) { |
| 97 | - case 'C': |
|
| 98 | - $currentTrx['credit_debit'] = static::CD_CREDIT; |
|
| 99 | - break; |
|
| 100 | - case 'D': |
|
| 101 | - $currentTrx['credit_debit'] = static::CD_DEBIT; |
|
| 102 | - break; |
|
| 103 | - case 'RC': |
|
| 104 | - $currentTrx['credit_debit'] = static::CD_CREDIT_CANCELLATION; |
|
| 105 | - break; |
|
| 106 | - case 'RD': |
|
| 107 | - $currentTrx['credit_debit'] = static::CD_DEBIT_CANCELLATION; |
|
| 108 | - break; |
|
| 109 | - default: |
|
| 110 | - throw new MT940Exception('c/d/rc/rd mark not found in: ' . $transaction); |
|
| 97 | + case 'C': |
|
| 98 | + $currentTrx['credit_debit'] = static::CD_CREDIT; |
|
| 99 | + break; |
|
| 100 | + case 'D': |
|
| 101 | + $currentTrx['credit_debit'] = static::CD_DEBIT; |
|
| 102 | + break; |
|
| 103 | + case 'RC': |
|
| 104 | + $currentTrx['credit_debit'] = static::CD_CREDIT_CANCELLATION; |
|
| 105 | + break; |
|
| 106 | + case 'RD': |
|
| 107 | + $currentTrx['credit_debit'] = static::CD_DEBIT_CANCELLATION; |
|
| 108 | + break; |
|
| 109 | + default: |
|
| 110 | + throw new MT940Exception('c/d/rc/rd mark not found in: ' . $transaction); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | $amount = $matches[3]; |
@@ -6,41 +6,41 @@ |
||
| 6 | 6 | |
| 7 | 7 | class TransactionTest extends \PHPUnit_Framework_TestCase |
| 8 | 8 | { |
| 9 | - public function test_getter_and_setter() |
|
| 10 | - { |
|
| 11 | - $obj = new Transaction(); |
|
| 9 | + public function test_getter_and_setter() |
|
| 10 | + { |
|
| 11 | + $obj = new Transaction(); |
|
| 12 | 12 | |
| 13 | - $this->assertNull($obj->getAccountNumber()); |
|
| 14 | - $this->assertNull($obj->getAmount()); |
|
| 15 | - $this->assertNull($obj->getBankCode()); |
|
| 16 | - $this->assertNull($obj->getBookingDate()); |
|
| 17 | - $this->assertNull($obj->getBookingText()); |
|
| 18 | - $this->assertNull($obj->getCreditDebit()); |
|
| 19 | - $this->assertNull($obj->getDescription1()); |
|
| 20 | - $this->assertNull($obj->getDescription2()); |
|
| 21 | - $this->assertNull($obj->getName()); |
|
| 22 | - $this->assertNull($obj->getValutaDate()); |
|
| 13 | + $this->assertNull($obj->getAccountNumber()); |
|
| 14 | + $this->assertNull($obj->getAmount()); |
|
| 15 | + $this->assertNull($obj->getBankCode()); |
|
| 16 | + $this->assertNull($obj->getBookingDate()); |
|
| 17 | + $this->assertNull($obj->getBookingText()); |
|
| 18 | + $this->assertNull($obj->getCreditDebit()); |
|
| 19 | + $this->assertNull($obj->getDescription1()); |
|
| 20 | + $this->assertNull($obj->getDescription2()); |
|
| 21 | + $this->assertNull($obj->getName()); |
|
| 22 | + $this->assertNull($obj->getValutaDate()); |
|
| 23 | 23 | |
| 24 | - $date = new \DateTime(); |
|
| 25 | - $this->assertSame('123456789', $obj->setAccountNumber('123456789')->getAccountNumber()); |
|
| 26 | - $this->assertSame(20.00, $obj->setAmount(20.00)->getAmount()); |
|
| 27 | - $this->assertSame('123456789', $obj->setBankCode('123456789')->getBankCode()); |
|
| 28 | - $this->assertSame($date, $obj->setBookingDate($date)->getBookingDate()); |
|
| 29 | - $this->assertSame($date, $obj->setValutaDate($date)->getValutaDate()); |
|
| 30 | - $this->assertSame('text', $obj->setBookingText('text')->getBookingText()); |
|
| 31 | - $this->assertSame(Transaction::CD_DEBIT, $obj->setCreditDebit(Transaction::CD_DEBIT)->getCreditDebit()); |
|
| 32 | - $this->assertSame(Transaction::CD_CREDIT, $obj->setCreditDebit(Transaction::CD_CREDIT)->getCreditDebit()); |
|
| 33 | - $this->assertSame('desc1', $obj->setDescription1('desc1')->getDescription1()); |
|
| 34 | - $this->assertSame('desc2', $obj->setDescription2('desc2')->getDescription2()); |
|
| 35 | - $this->assertSame('name', $obj->setName('name')->getName()); |
|
| 36 | - } |
|
| 24 | + $date = new \DateTime(); |
|
| 25 | + $this->assertSame('123456789', $obj->setAccountNumber('123456789')->getAccountNumber()); |
|
| 26 | + $this->assertSame(20.00, $obj->setAmount(20.00)->getAmount()); |
|
| 27 | + $this->assertSame('123456789', $obj->setBankCode('123456789')->getBankCode()); |
|
| 28 | + $this->assertSame($date, $obj->setBookingDate($date)->getBookingDate()); |
|
| 29 | + $this->assertSame($date, $obj->setValutaDate($date)->getValutaDate()); |
|
| 30 | + $this->assertSame('text', $obj->setBookingText('text')->getBookingText()); |
|
| 31 | + $this->assertSame(Transaction::CD_DEBIT, $obj->setCreditDebit(Transaction::CD_DEBIT)->getCreditDebit()); |
|
| 32 | + $this->assertSame(Transaction::CD_CREDIT, $obj->setCreditDebit(Transaction::CD_CREDIT)->getCreditDebit()); |
|
| 33 | + $this->assertSame('desc1', $obj->setDescription1('desc1')->getDescription1()); |
|
| 34 | + $this->assertSame('desc2', $obj->setDescription2('desc2')->getDescription2()); |
|
| 35 | + $this->assertSame('name', $obj->setName('name')->getName()); |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - public function test_get_signed_amount() |
|
| 39 | - { |
|
| 40 | - $obj = new Transaction(); |
|
| 41 | - $this->assertSame(-20.00, $obj->setCreditDebit(Transaction::CD_DEBIT)->setAmount(20.00)->getSignedAmount()); |
|
| 42 | - $this->assertSame(-20.00, $obj->setCreditDebit(Transaction::CD_CREDIT_CANCELLATION)->setAmount(20.00)->getSignedAmount()); |
|
| 43 | - $this->assertSame(20.00, $obj->setCreditDebit(Transaction::CD_CREDIT)->setAmount(20.00)->getSignedAmount()); |
|
| 44 | - $this->assertSame(20.00, $obj->setCreditDebit(Transaction::CD_DEBIT_CANCELLATION)->setAmount(20.00)->getSignedAmount()); |
|
| 45 | - } |
|
| 38 | + public function test_get_signed_amount() |
|
| 39 | + { |
|
| 40 | + $obj = new Transaction(); |
|
| 41 | + $this->assertSame(-20.00, $obj->setCreditDebit(Transaction::CD_DEBIT)->setAmount(20.00)->getSignedAmount()); |
|
| 42 | + $this->assertSame(-20.00, $obj->setCreditDebit(Transaction::CD_CREDIT_CANCELLATION)->setAmount(20.00)->getSignedAmount()); |
|
| 43 | + $this->assertSame(20.00, $obj->setCreditDebit(Transaction::CD_CREDIT)->setAmount(20.00)->getSignedAmount()); |
|
| 44 | + $this->assertSame(20.00, $obj->setCreditDebit(Transaction::CD_DEBIT_CANCELLATION)->setAmount(20.00)->getSignedAmount()); |
|
| 45 | + } |
|
| 46 | 46 | } |