AllowanceCharge::setBaseAmount()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 3
rs 10
c 1
b 0
f 0
1
<?php
2
3
/**
4
 * MÓDULO DE EMISIÓN ELECTRÓNICA F72X
5
 * UBL 2.1
6
 * Version 1.0
7
 * 
8
 * Copyright 2019, Jaime Cruz
9
 */
10
11
namespace F72X\UblComponent;
12
13
use F72X\Sunat\Operations;
14
use Sabre\Xml\Writer;
15
16
class AllowanceCharge extends BaseComponent {
17
18
    const DECIMALS = 2;
19
20
    protected $currencyID;
21
22
    /**
23
     * 
24
     * @var string True|False
25
     * True: Para cargos
26
     * False: Para descuentos
27
     */
28
    protected $ChargeIndicator;
29
30
    /**
31
     *
32
     * @var string
33
     * Catálogo #53
34
     *     00: OTROS DESCUENTOS
35
     *     [50-55]: CARGOS
36
     */
37
    protected $AllowanceChargeReasonCode;
38
39
    /** @var float */
40
    protected $MultiplierFactorNumeric;
41
42
    /** @var float */
43
    protected $Amount;
44
45
    /** @var float */
46
    protected $BaseAmount;
47
    protected $validations = [
48
        'currencyID',
49
        'ChargeIndicator',
50
        'AllowanceChargeReasonCode',
51
        'Amount',
52
        'BaseAmount'
53
    ];
54
55
    function xmlSerialize(Writer $writer) {
56
        $me = $this;
57
        $me->validate();
58
        $writer->write([
59
            SchemaNS::CBC . 'ChargeIndicator'           => $me->ChargeIndicator,
60
            SchemaNS::CBC . 'AllowanceChargeReasonCode' => $me->AllowanceChargeReasonCode
61
        ]);
62
        if ($me->MultiplierFactorNumeric) {
63
            $writer->write([
64
                SchemaNS::CBC . 'MultiplierFactorNumeric' => Operations::formatAmount($this->MultiplierFactorNumeric, self::DECIMALS),
65
            ]);
66
        }
67
        $writer->write([
68
            [
69
                'name' => SchemaNS::CBC . 'Amount',
70
                'value' => Operations::formatAmount($this->Amount, self::DECIMALS),
71
                'attributes' => [
72
                    'currencyID' => $me->currencyID
73
                ]
74
            ],
75
            [
76
                'name' => SchemaNS::CBC . 'BaseAmount',
77
                'value' => Operations::formatAmount($this->BaseAmount, self::DECIMALS),
78
                'attributes' => [
79
                    'currencyID' => $me->currencyID
80
                ]
81
            ]
82
        ]);
83
    }
84
85
    public function getCurrencyID() {
86
        return $this->currencyID;
87
    }
88
89
    public function setCurrencyID($currencyID) {
90
        $this->currencyID = $currencyID;
91
        return $this;
92
    }
93
94
    public function getChargeIndicator() {
95
        return $this->ChargeIndicator;
96
    }
97
98
    /**
99
     * 
100
     * @param string $ChargeIndicator True|False
101
     *     True: Para cargos
102
     *     False: Para descuentos
103
     * @return $this
104
     */
105
    public function setChargeIndicator($ChargeIndicator) {
106
        $this->ChargeIndicator = $ChargeIndicator;
107
        return $this;
108
    }
109
110
    public function getAllowanceChargeReasonCode() {
111
        return $this->AllowanceChargeReasonCode;
112
    }
113
114
    public function setAllowanceChargeReasonCode($AllowanceChargeReasonCode) {
115
        $this->AllowanceChargeReasonCode = $AllowanceChargeReasonCode;
116
        return $this;
117
    }
118
119
    public function getMultiplierFactorNumeric() {
120
        return $this->MultiplierFactorNumeric;
121
    }
122
123
    public function setMultiplierFactorNumeric($MultiplierFactorNumeric) {
124
        $this->MultiplierFactorNumeric = $MultiplierFactorNumeric;
125
        return $this;
126
    }
127
128
    public function getAmount() {
129
        return $this->Amount;
130
    }
131
132
    public function setAmount($Amount) {
133
        $this->Amount = $Amount;
134
        return $this;
135
    }
136
137
    public function getBaseAmount() {
138
        return $this->BaseAmount;
139
    }
140
141
    public function setBaseAmount($BaseAmount) {
142
        $this->BaseAmount = $BaseAmount;
143
        return $this;
144
    }
145
146
}
147