|
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
|
|
|
declare(strict_types=1); |
|
10
|
|
|
|
|
11
|
|
|
namespace Moip\Magento2\Block\Sales; |
|
12
|
|
|
|
|
13
|
|
|
use Magento\Framework\DataObject; |
|
|
|
|
|
|
14
|
|
|
use Magento\Framework\View\Element\Template; |
|
|
|
|
|
|
15
|
|
|
use Magento\Sales\Model\Order; |
|
|
|
|
|
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Class Totals - Template. |
|
19
|
|
|
*/ |
|
20
|
|
|
class Totals extends Template |
|
21
|
|
|
{ |
|
22
|
|
|
/** |
|
23
|
|
|
* @var Order |
|
24
|
|
|
*/ |
|
25
|
|
|
protected $_order; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @var DataObject |
|
29
|
|
|
*/ |
|
30
|
|
|
protected $_source; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @return bool |
|
34
|
|
|
*/ |
|
35
|
|
|
public function displayFullSummary() |
|
36
|
|
|
{ |
|
37
|
|
|
return true; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Get data (totals) source model. |
|
42
|
|
|
* |
|
43
|
|
|
* @return DataObject |
|
44
|
|
|
*/ |
|
45
|
|
|
public function getSource() |
|
46
|
|
|
{ |
|
47
|
|
|
return $this->_source; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @return store |
|
|
|
|
|
|
52
|
|
|
*/ |
|
53
|
|
|
public function getStore() |
|
54
|
|
|
{ |
|
55
|
|
|
return $this->_order->getStore(); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* @return Order |
|
60
|
|
|
*/ |
|
61
|
|
|
public function getOrder() |
|
62
|
|
|
{ |
|
63
|
|
|
return $this->_order; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* Initialize payment moip_interest totals. |
|
68
|
|
|
* |
|
69
|
|
|
* @return $this |
|
70
|
|
|
*/ |
|
71
|
|
|
public function initTotals() |
|
72
|
|
|
{ |
|
73
|
|
|
$parent = $this->getParentBlock(); |
|
74
|
|
|
$this->_order = $parent->getOrder(); |
|
75
|
|
|
$this->_source = $parent->getSource(); |
|
76
|
|
|
|
|
77
|
|
|
if (!$this->_source->getMoipInterestAmount() || (int) $this->_source->getMoipInterestAmount() === 0) { |
|
78
|
|
|
return $this; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
$valueInterest = $this->_source->getMoipInterestAmount(); |
|
82
|
|
|
$label = $this->getLabelByInterest($valueInterest); |
|
83
|
|
|
$moipInterest = new DataObject( |
|
84
|
|
|
[ |
|
85
|
|
|
'code' => 'moip_interest', |
|
86
|
|
|
'strong' => false, |
|
87
|
|
|
'value' => $valueInterest, |
|
88
|
|
|
'label' => $label, |
|
89
|
|
|
] |
|
90
|
|
|
); |
|
91
|
|
|
|
|
92
|
|
|
if ((int) $valueInterest !== 0.0000) { |
|
93
|
|
|
$parent->addTotal($moipInterest, 'moip_interest'); |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
return $this; |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* Get Subtotal label by Interest. |
|
101
|
|
|
* |
|
102
|
|
|
* @param $interest | float |
|
|
|
|
|
|
103
|
|
|
* |
|
104
|
|
|
* @return Phrase |
|
105
|
|
|
*/ |
|
106
|
|
|
public function getLabelByInterest($interest) |
|
107
|
|
|
{ |
|
108
|
|
|
if ($interest >= 0) { |
|
109
|
|
|
return __('Installment Interest'); |
|
|
|
|
|
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
return __('Discount Cash'); |
|
113
|
|
|
} |
|
114
|
|
|
} |
|
115
|
|
|
|
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