Passed
Push — master ( a1e314...1d4724 )
by Luiz Kim
01:33
created

NFePHP::getSignData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 17
nc 1
nop 1
dl 0
loc 21
rs 9.7
c 0
b 0
f 0
1
<?php
2
3
namespace ControleOnline\Library;
4
5
use ControleOnline\Entity\Order;
0 ignored issues
show
Bug introduced by
The type ControleOnline\Entity\Order 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...
6
use ControleOnline\Entity\Product;
0 ignored issues
show
Bug introduced by
The type ControleOnline\Entity\Product 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...
7
use Doctrine\ORM\EntityManagerInterface;
0 ignored issues
show
Bug introduced by
The type Doctrine\ORM\EntityManagerInterface 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...
8
use Symfony\Component\Security\Core\Security;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Security\Core\Security 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...
9
use NFePHP\Common\Certificate;
0 ignored issues
show
Bug introduced by
The type NFePHP\Common\Certificate 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...
10
11
class NFePHP
12
{
13
    protected $make;
14
    protected $model;
15
    protected $tools;
16
    protected $version;
17
18
    public function __construct(
19
        protected EntityManagerInterface $manager,
20
        protected Security $security,
21
    ) {
22
    }
23
24
    //ide OBRIGATÓRIA
25
    protected function makeIde(Order $order)
0 ignored issues
show
Unused Code introduced by
The parameter $order is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

25
    protected function makeIde(/** @scrutinizer ignore-unused */ Order $order)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
26
    {
27
28
        $std = new \stdClass();
29
        $std->cUF = 14;
30
        $std->cNF = '03701267';
31
        $std->natOp = 'VENDA CONSUMIDOR';
32
        $std->mod = 65;
33
        $std->serie = 1;
34
        $std->nNF = 100;
35
        $std->dhEmi = (new \DateTime())->format('Y-m-d\TH:i:sP');
36
        $std->dhSaiEnt = null;
37
        $std->tpNF = 1;
38
        $std->idDest = 1;
39
        $std->cMunFG = 1400100;
40
        $std->tpImp = 1;
41
        $std->tpEmis = 1;
42
        $std->cDV = 2;
43
        $std->tpAmb = 2;
44
        $std->finNFe = 1;
45
        $std->indFinal = 1;
46
        $std->indPres = 1;
47
        $std->procEmi = 3;
48
        $std->verProc = '4.13';
49
        $std->dhCont = null;
50
        $std->xJust = null;
51
        $this->make->tagIde($std);
52
    }
53
54
    //emit OBRIGATÓRIA
55
    protected function makeEmit(Order $order)
56
    {
57
58
        $std = new \stdClass();
59
        $std->xNome = 'SUA RAZAO SOCIAL LTDA';
60
        $std->xFant = 'RAZAO';
61
        $std->IE = '111111111';
62
        $std->IEST = null;
63
        //$std->IM = '95095870';
64
        $std->CNAE = '4642701';
65
        $std->CRT = 1;
66
        $std->CNPJ = '99999999999999';
67
        //$std->CPF = '12345678901'; //NÃO PASSE TAGS QUE NÃO EXISTEM NO CASO
68
        $this->make->tagemit($std);
69
70
        //enderEmit OBRIGATÓRIA
71
        $this->makeEmitAddress($order);
72
    }
73
74
    protected function makeEmitAddress(Order $order)
0 ignored issues
show
Unused Code introduced by
The parameter $order is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

74
    protected function makeEmitAddress(/** @scrutinizer ignore-unused */ Order $order)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
75
    {
76
        $std = new \stdClass();
77
        $std->xLgr = 'Avenida Getúlio Vargas';
78
        $std->nro = '5022';
79
        $std->xCpl = 'LOJA 42';
80
        $std->xBairro = 'CENTRO';
81
        $std->cMun = 1400100;
82
        $std->xMun = 'BOA VISTA';
83
        $std->UF = 'RR';
84
        $std->CEP = '69301030';
85
        $std->cPais = 1058;
86
        $std->xPais = 'Brasil';
87
        $std->fone = '55555555';
88
        $this->make->tagenderemit($std);
89
    }
90
    //dest OPCIONAL
91
    protected function makeDest(Order $order)
92
    {
93
        $std = new \stdClass();
94
        $std->xNome = 'Eu Ltda';
95
        $std->CNPJ = '01234123456789';
96
        //$std->CPF = '12345678901';
97
        //$std->idEstrangeiro = 'AB1234';
98
        $std->indIEDest = 9;
99
        //$std->IE = '';
100
        //$std->ISUF = '12345679';
101
        //$std->IM = 'XYZ6543212';
102
        $std->email = '[email protected]';
103
        $dest = $this->make->tagdest($std);
0 ignored issues
show
Unused Code introduced by
The assignment to $dest is dead and can be removed.
Loading history...
104
105
106
        $this->makeDestAddress($order);
107
    }
108
    //enderDest OPCIONAL
109
    protected function makeDestAddress(Order $order)
0 ignored issues
show
Unused Code introduced by
The parameter $order is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

109
    protected function makeDestAddress(/** @scrutinizer ignore-unused */ Order $order)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
110
    {
111
112
        $std = new \stdClass();
113
        $std->xLgr = 'Avenida Sebastião Diniz';
114
        $std->nro = '458';
115
        $std->xCpl = null;
116
        $std->xBairro = 'CENTRO';
117
        $std->cMun = 1400100;
118
        $std->xMun = 'Boa Vista';
119
        $std->UF = 'RR';
120
        $std->CEP = '69301088';
121
        $std->cPais = 1058;
122
        $std->xPais = 'Brasil';
123
        $std->fone = '1111111111';
124
        $this->make->tagenderdest($std);
125
    }
126
127
    //prod OBRIGATÓRIA
128
    protected function makeProds(Order $order)
129
    {
130
        $orderProducts  = $order->getOrderProducts();
131
        $item = 1;
132
        foreach ($orderProducts as $orderProducts) {
133
            $product = $orderProducts->getProduct();
134
135
            $std = new \stdClass();
136
            $std->item = $item;
137
            $std->cProd = '00341';
138
            $std->cEAN = 'SEM GTIN';
139
            $std->cEANTrib = 'SEM GTIN';
140
            $std->xProd = 'Produto com serviço';
141
            $std->NCM = '96081000';
142
            $std->CFOP = '5933';
143
            $std->uCom = 'JG';
144
            $std->uTrib = 'JG';
145
            $std->cBarra = NULL;
146
            $std->cBarraTrib = NULL;
147
            $std->qCom = '1';
148
            $std->qTrib = '1';
149
            $std->vUnCom = '200';
150
            $std->vUnTrib = '200';
151
            $std->vProd = '200';
152
            $std->vDesc = NULL;
153
            $std->vOutro = NULL;
154
            $std->vSeg = NULL;
155
            $std->vFrete = NULL;
156
            $std->cBenef = NULL;
157
            $std->xPed = NULL;
158
            $std->nItemPed = NULL;
159
            $std->indTot = 1;
160
            $this->make->tagprod($std);
161
            $this->makeImpostos($product, $item);
162
        }
163
    }
164
    protected function makeImpostos(Product $product, $item)
165
    {
166
        $this->makePIS($product, $item);
167
        $this->makeCOFINS($product, $item);
168
        $this->makeISSQN($product, $item);
169
170
        //Imposto
171
        $std = new \stdClass();
172
        $std->item = $item; //item da NFe
173
        $std->vTotTrib = 0;
174
        $this->make->tagimposto($std);
175
176
177
178
        $std = new \stdClass();
179
        $this->make->tagICMSTot($std);
180
181
        $std = new \stdClass();
182
        $std->dCompet = '2010-09-12';
183
        $std->cRegTrib = 6;
184
        $this->make->tagISSQNTot($std);
185
        $this->make->tagISSQNTot($std);
186
    }
187
188
    protected function makeInfNFe($version)
189
    {
190
        //infNFe OBRIGATÓRIA
191
        $std = new \stdClass();
192
        $std->Id = '';
193
        $std->versao =  $version;
194
        $this->make->taginfNFe($std);
195
    }
196
197
    protected function makeISSQN(Product $product, $item)
0 ignored issues
show
Unused Code introduced by
The parameter $product is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

197
    protected function makeISSQN(/** @scrutinizer ignore-unused */ Product $product, $item)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
198
    {
199
        // Monta a tag de impostos mas não adiciona no xml
200
        $std = new \stdClass();
201
        $std->item = $item; //item da NFe
202
        $std->vBC = 2.0;
203
        $std->vAliq = 8.0;
204
        $std->vISSQN = 0.16;
205
        $std->cMunFG = 1300029;
206
        $std->cMun = 1300029;
207
        $std->cPais = '1058';
208
        $std->cListServ = '01.01';
209
        $std->indISS = 1;
210
        $std->indIncentivo = 2;
211
        // Adiciona a tag de imposto ISSQN no xml
212
        $this->make->tagISSQN($std);
213
    }
214
215
    protected function makePIS(Product $product, $item)
0 ignored issues
show
Unused Code introduced by
The parameter $product is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

215
    protected function makePIS(/** @scrutinizer ignore-unused */ Product $product, $item)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
216
    {
217
        //PIS
218
        $std = new \stdClass();
219
        $std->item = $item; //item da NFe
220
        $std->CST = '99';
221
        $std->vBC = 200;
222
        $std->pPIS = 0.65;
223
        $std->vPIS = 13;
224
        $this->make->tagPIS($std);
225
    }
226
    protected function makeCOFINS(Product $product, $item)
0 ignored issues
show
Unused Code introduced by
The parameter $product is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

226
    protected function makeCOFINS(/** @scrutinizer ignore-unused */ Product $product, $item)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
227
    {
228
        //COFINS
229
        $std = new \stdClass();
230
        $std->item = $item; //item da NFe
231
        $std->CST = '99';
232
        $std->vBC = 200;
233
        $std->pCOFINS = 3;
234
        $std->vCOFINS = 60;
235
        $this->make->tagCOFINS($std);
236
    }
237
238
    protected function sign(Order $order)
0 ignored issues
show
Unused Code introduced by
The parameter $order is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

238
    protected function sign(/** @scrutinizer ignore-unused */ Order $order)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
239
    {
240
        $this->tools->model($this->model);
241
        //$tools->disableCertValidation(true); //tem que desabilitar
242
        return $this->tools->signNFe($this->make->getXML());
243
    }
244
245
    protected function getCertificate()
246
    {
247
        $pfxcontent = file_get_contents('fixtures/expired_certificate.pfx');
248
        return Certificate::readPfx($pfxcontent, 'associacao');
249
    }
250
251
    protected function getSignData(Order $order)
0 ignored issues
show
Unused Code introduced by
The parameter $order is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

251
    protected function getSignData(/** @scrutinizer ignore-unused */ Order $order)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
252
    {
253
        $arr = [
254
            "atualizacao" => "2017-02-20 09:11:21",
255
            "tpAmb"       => 2,
256
            "razaosocial" => "SUA RAZAO SOCIAL LTDA",
257
            "cnpj"        => "99999999999999",
258
            "siglaUF"     => "SP",
259
            "schemes"     => "PL_009_V4",
260
            "versao"      => '4.00',
261
            "tokenIBPT"   => "AAAAAAA",
262
            "CSC"         => "GPB0JBWLUR6HWFTVEAS6RJ69GPCROFPBBB8G",
263
            "CSCid"       => "000001",
264
            "proxyConf"   => [
265
                "proxyIp"   => "",
266
                "proxyPort" => "",
267
                "proxyUser" => "",
268
                "proxyPass" => ""
269
            ]
270
        ];
271
        return json_encode($arr);
272
    }
273
274
    protected function makeTransp(Order $order)
0 ignored issues
show
Unused Code introduced by
The parameter $order is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

274
    protected function makeTransp(/** @scrutinizer ignore-unused */ Order $order)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
275
    {
276
        //transp OBRIGATÓRIA
277
        $std = new \stdClass();
278
        $this->make->tagtransp($std);
279
    }
280
281
282
    protected function makePag(Order $order)
0 ignored issues
show
Unused Code introduced by
The parameter $order is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

282
    protected function makePag(/** @scrutinizer ignore-unused */ Order $order)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
283
    {
284
        //pag OBRIGATÓRIA
285
        $std = new \stdClass();
286
        $std->vTroco = 0;
287
        $this->make->tagpag($std);
288
    }
289
290
291
    protected function makedetPag(Order $order)
0 ignored issues
show
Unused Code introduced by
The parameter $order is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

291
    protected function makedetPag(/** @scrutinizer ignore-unused */ Order $order)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
292
    {
293
        //detPag OBRIGATÓRIA
294
        $std = new \stdClass();
295
        $std->indPag = '0';
296
        $std->xPag = NULL;
297
        $std->tPag = '01';
298
        $std->vPag = 2.01;
299
        $this->make->tagdetpag($std);
300
    }
301
    protected function makeInfRespTec()
302
    {
303
304
        $std = new \stdClass();
305
        $std->CNPJ = '99999999999999'; //CNPJ da pessoa jurídica responsável pelo sistema utilizado na emissão do documento fiscal eletrônico
306
        $std->xContato = 'Fulano de Tal'; //Nome da pessoa a ser contatada
307
        $std->email = '[email protected]'; //E-mail da pessoa jurídica a ser contatada
308
        $std->fone = '1155551122'; //Telefone da pessoa jurídica/física a ser contatada
309
        //$std->CSRT = 'G8063VRTNDMO886SFNK5LDUDEI24XJ22YIPO'; //Código de Segurança do Responsável Técnico
310
        //$std->idCSRT = '01'; //Identificador do CSRT
311
        $this->make->taginfRespTec($std);
312
    }
313
}
314