|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Copyright © Wirecard Brasil. All rights reserved. |
|
4
|
|
|
* |
|
5
|
|
|
* @author Bruno Elisei <[email protected]> |
|
6
|
|
|
* See COPYING.txt for license details. |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace Moip\Magento2\Observer; |
|
10
|
|
|
|
|
11
|
|
|
use Magento\Framework\Event\ObserverInterface; |
|
|
|
|
|
|
12
|
|
|
use Moip\Magento2\Block\Adminhtml\Sales\Creditmemo as CreditmemoBlock; |
|
13
|
|
|
use Moip\Magento2\Model\Ui\ConfigProviderBoleto; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Class SetBoletoDataToCreditmemo - Set refund data of boleto. |
|
17
|
|
|
*/ |
|
18
|
|
|
class SetBoletoDataToCreditmemo implements ObserverInterface |
|
19
|
|
|
{ |
|
20
|
|
|
/** |
|
21
|
|
|
* Set boleto data to creditmemo before register. |
|
22
|
|
|
* |
|
23
|
|
|
* @param \Magento\Framework\Event\Observer $observer |
|
24
|
|
|
* |
|
25
|
|
|
* @return $this |
|
26
|
|
|
*/ |
|
27
|
|
|
public function execute(\Magento\Framework\Event\Observer $observer) |
|
|
|
|
|
|
28
|
|
|
{ |
|
29
|
|
|
$input = $observer->getEvent()->getInput(); |
|
30
|
|
|
/** @var \Magento\Sales\Model\Order\Creditmemo $creditmemo */ |
|
31
|
|
|
$creditmemo = $observer->getEvent()->getCreditmemo(); |
|
32
|
|
|
$order = $creditmemo->getOrder(); |
|
33
|
|
|
|
|
34
|
|
|
if ($order->getPayment()->getMethodInstance()->getCode() === ConfigProviderBoleto::CODE) { |
|
35
|
|
|
$bankNumber = !empty($input[CreditmemoBlock::BANK_NUMBER]) ? $input[CreditmemoBlock::BANK_NUMBER] : null; |
|
36
|
|
|
$creditmemo->setData(CreditmemoBlock::BANK_NUMBER, $bankNumber); |
|
37
|
|
|
|
|
38
|
|
|
$agencyNumber = !empty($input[CreditmemoBlock::AGENCY_NUMBER]) ? $input[CreditmemoBlock::AGENCY_NUMBER] : null; |
|
39
|
|
|
$creditmemo->setData(CreditmemoBlock::AGENCY_NUMBER, $agencyNumber); |
|
40
|
|
|
|
|
41
|
|
|
$agencyCheckNumber = !empty($input[CreditmemoBlock::AGENCY_CHECK_NUMBER]) ? $input[CreditmemoBlock::AGENCY_CHECK_NUMBER] : null; |
|
42
|
|
|
$creditmemo->setData(CreditmemoBlock::AGENCY_CHECK_NUMBER, $agencyCheckNumber); |
|
43
|
|
|
|
|
44
|
|
|
$accountNumber = !empty($input[CreditmemoBlock::ACCOUNT_NUMBER]) ? $input[CreditmemoBlock::ACCOUNT_NUMBER] : null; |
|
45
|
|
|
$creditmemo->setData(CreditmemoBlock::ACCOUNT_NUMBER, $accountNumber); |
|
46
|
|
|
|
|
47
|
|
|
$accountCheckNumber = !empty($input[CreditmemoBlock::ACCOUNT_CHECK_NUMBER]) ? $input[CreditmemoBlock::ACCOUNT_CHECK_NUMBER] : null; |
|
48
|
|
|
$creditmemo->setData(CreditmemoBlock::ACCOUNT_CHECK_NUMBER, $accountCheckNumber); |
|
49
|
|
|
|
|
50
|
|
|
$holderFullname = !empty($input[CreditmemoBlock::HOLDER_FULLNAME]) ? $input[CreditmemoBlock::HOLDER_FULLNAME] : null; |
|
51
|
|
|
$creditmemo->setData(CreditmemoBlock::HOLDER_FULLNAME, $holderFullname); |
|
52
|
|
|
|
|
53
|
|
|
$holderDocumment = !empty($input[CreditmemoBlock::HOLDER_DOCUMENT_NUMBER]) ? $input[CreditmemoBlock::HOLDER_DOCUMENT_NUMBER] : null; |
|
54
|
|
|
$creditmemo->setData(CreditmemoBlock::HOLDER_DOCUMENT_NUMBER, $holderDocumment); |
|
55
|
|
|
|
|
56
|
|
|
$comment = !empty($input[CreditmemoBlock::CREDITMEMO_COMMENT_TEXT]) ? $input[CreditmemoBlock::CREDITMEMO_COMMENT_TEXT] : null; |
|
57
|
|
|
$comment = $comment.'\n'.__('Refund Request to Bank %1, Agency Number %2, Agency Check Number %3, Account Number %4, Account Check Number %5, Holder Name %6, Holder Tax Document %7', $bankNumber, $agencyNumber, $agencyCheckNumber, $accountNumber, $accountCheckNumber, $holderFullname, $holderDocumment); |
|
|
|
|
|
|
58
|
|
|
$creditmemo->setComment($comment); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
return $this; |
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths