MoipInterest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 26
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A collect() 0 19 2
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\Model\Order\Total\Creditmemo;
12
13
use Magento\Sales\Model\Order\Creditmemo;
0 ignored issues
show
Bug introduced by
The type Magento\Sales\Model\Order\Creditmemo was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
use Magento\Sales\Model\Order\Creditmemo\Total\AbstractTotal;
0 ignored issues
show
Bug introduced by
The type Magento\Sales\Model\Orde...emo\Total\AbstractTotal was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
15
16
/**
17
 * Class MoipInterest - Model data Total Creditmemo.
18
 */
19
class MoipInterest extends AbstractTotal
20
{
21
    /**
22
     * @param Creditmemo $creditmemo
23
     *
24
     * @return $this
25
     */
26
    public function collect(Creditmemo $creditmemo)
27
    {
28
        $order = $creditmemo->getOrder();
29
30
        $moipInterest = $order->getMoipInterestAmountInvoiced();
31
        $baseMoipInterest = $order->getBaseMoipInterestAmountInvoiced();
32
33
        if ((int) $moipInterest === 0) {
34
            return $this;
35
        }
36
37
        $creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $moipInterest);
38
        $creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $baseMoipInterest);
39
        $creditmemo->setMoipInterestAmount($moipInterest);
40
        $creditmemo->setBaseMoipInterestAmount($baseMoipInterest);
41
        $order->setMoipInterestAmountRefunded($moipInterest);
42
        $order->setBaseMoipInterestAmountRefunded($baseMoipInterest);
43
44
        return $this;
45
    }
46
}
47