├── .gitignore
├── .scrutinizer.yml
├── .travis.yml
├── LICENSE
├── README.md
├── check-standards
├── composer.json
├── fix-to-psr12
├── phpunit.xml
├── run-test
├── src
└── Multiverse
│ └── Notazz
│ ├── DSL
│ ├── AliquotasBuilder.php
│ ├── DestinationBuilder.php
│ ├── DocumentBuilder.php
│ ├── Exceptions
│ │ ├── CantAddEmailException.php
│ │ └── MethodNotFoundException.php
│ ├── NotaFiscalBuilder.php
│ ├── ProductsBuilder.php
│ ├── ServiceBuilder.php
│ ├── ShippingBuilder.php
│ ├── ShippingCarrierBuilder.php
│ ├── ShippingVehiclesBuilder.php
│ ├── ShippingVolumesBuilder.php
│ └── Tools
│ │ └── Formatter.php
│ ├── Destination.php
│ ├── Exceptions
│ └── ErrorStatusProcessamentoException.php
│ ├── NFSe.php
│ ├── NFSe
│ ├── Aliquotas.php
│ ├── Document.php
│ └── Service.php
│ ├── NFe.php
│ ├── NFe
│ ├── Document.php
│ ├── ProductItem.php
│ ├── Products.php
│ ├── Shipping.php
│ ├── ShippingCarrier.php
│ ├── ShippingVehicles.php
│ └── ShippingVolumes.php
│ ├── NotaFiscal.php
│ └── Resource.php
└── tests
├── FirstTest.php
├── NotafiscalNFSeSendTest.php
├── NotafiscalNFSeTest.php
├── NotafiscalNFeSendTest.php
├── NotafiscalNFeTest.php
└── ToolsFormatterTest.php
/.gitignore:
--------------------------------------------------------------------------------
1 | vendor
2 | composer.lock
3 | build
--------------------------------------------------------------------------------
/.scrutinizer.yml:
--------------------------------------------------------------------------------
1 | build:
2 | nodes:
3 | analysis:
4 | project_setup:
5 | override: true
6 | tests:
7 | override: [php-scrutinizer-run]
8 |
9 | filter:
10 | excluded_paths:
11 | - tests/*
12 | - vendor/*
13 |
14 | checks:
15 | php:
16 | remove_extra_empty_lines: true
17 | remove_php_closing_tag: true
18 | remove_trailing_whitespace: true
19 | fix_use_statements:
20 | remove_unused: true
21 | preserve_multiple: false
22 | preserve_blanklines: true
23 | order_alphabetically: false
24 | fix_php_opening_tag: true
25 | fix_linefeed: true
26 | fix_line_ending: true
27 | fix_identation_4spaces: true
28 | fix_doc_comments: true
29 |
30 | tools:
31 | external_code_coverage:
32 | timeout: 600
33 | runs: 3
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | dist: trusty
2 | language: php
3 |
4 | php:
5 | - 7.2
6 | - 7.3
7 | - 7.4
8 |
9 | # This triggers builds to run on the new TravisCI infrastructure.
10 | # See: http://docs.travis-ci.com/user/workers/container-based-infrastructure/
11 | sudo: false
12 |
13 | ## Cache composer
14 | cache:
15 | directories:
16 | - $HOME/.composer/cache
17 |
18 | before_script:
19 | - travis_retry composer update --no-interaction --prefer-dist
20 |
21 | script:
22 | - vendor/bin/phpcs --standard=psr12 src/
23 | - vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover
24 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Multiverse Marketing
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # SDK PHP Notazz
2 | [](https://travis-ci.org/leoqbc/sdk-php-notazz)
3 | [](https://packagist.org/packages/multiverse/notazzsdk)
4 | [](https://packagist.org/packages/multiverse/notazzsdk)
5 | [](https://packagist.org/packages/multiverse/notazzsdk)
6 |
7 | [Documentação da API oficial](https://app.notazz.com/docs/api/)
8 |
9 | SDK e DSL em PHP para emissão de nota fiscal NFE e NFSE
10 |
11 | ### Intalação da SDK
12 | `$ composer require multiverse/notazzsdk`
13 |
14 |
15 | ## Abaixo exemplo de uso
16 | ###### Emissão da NF-e
17 | ```php
18 | // Example NFE
19 | use Multiverse\Notazz\DSL\NotaFiscalBuilder;
20 |
21 | $notafiscal = new NotaFiscalBuilder();
22 |
23 | $result =
24 | $notafiscal
25 | ->key('123') // Notazz Api key
26 | ->destination()
27 | ->name('John Doe')
28 | ->taxid('00000000272')
29 | ->taxtype('F')
30 | ->street('NÃO INFORMADO')
31 | ->number('S/N')
32 | ->district('NÃO INFORMADO')
33 | ->city('São Paulo')
34 | ->uf('SP')
35 | ->zipcode('02102000')
36 | ->email('teste@gmail.com')
37 | ->sendEmailList()
38 | ->add('teste1@gmail.com')
39 | ->add('teste2@gmail.com')
40 | ->end()
41 | ->phone(11955555555)
42 | ->document()
43 | ->nfe()
44 | ->basevalue(70.30)
45 | ->description('Descrição teste')
46 | ->issue_date('2019-07-05 18:11:30')
47 | ->products()
48 | ->add()
49 | ->cod(123)
50 | ->name('Escova de dente Cepacol')
51 | ->qtd(2)
52 | ->unitary_value(15.20)
53 | ->save()
54 | ->add()
55 | ->cod(124)
56 | ->name('Pano de prato para cozinha')
57 | ->qtd(1)
58 | ->unitary_value(55.10)
59 | ->save()
60 | ->shipping()
61 | ->value(100.00)
62 | ->mode(0)
63 | ->vehicles()
64 | ->placa('ZZZ1100')
65 | ->uf('MG')
66 | ->volumes()
67 | ->qtd(1)
68 | ->species('CAIXA')
69 | ->netWeight(10.500)
70 | ->grossWeight(12.000)
71 | ->carrier()
72 | ->name('Empresa Brasileira de Correios e Telégrafos')
73 | ->taxid('34028316002742')
74 | ->ie(12345678)
75 | ->street('Rua de teste')
76 | ->number(123)
77 | ->district('Centro')
78 | ->city('Belo Horizonte')
79 | ->uf('MG')
80 | ->save()
81 | ->make()
82 | ;
83 | ```
84 | ###### Emissão da NFS-e
85 | ```php
86 | // Example NFSE
87 | use Multiverse\Notazz\DSL\NotaFiscalBuilder;
88 |
89 | $result = $this->notafiscal
90 | ->key('123')
91 | ->destination()
92 | ->name('Leonardo Tumadjian')
93 | ->taxid('00000000272')
94 | ->taxtype('F')
95 | ->street('NÃO INFORMADO')
96 | ->number('S/N')
97 | ->district('NÃO INFORMADO')
98 | ->city('São Paulo')
99 | ->uf('SP')
100 | ->zipcode('02102000')
101 | ->email('teste@gmail.com')
102 | ->sendEmailList()
103 | ->add('teste1@gmail.com')
104 | ->add('teste2@gmail.com')
105 | ->end()
106 | ->phone(11955555555)
107 | ->document()
108 | ->nfse()
109 | ->basevalue(0.10)
110 | ->description('Descrição teste')
111 | ->issue_date('2019-07-05 18:11:30')
112 | ->service()
113 | ->description('Teste')
114 | ->listLc116(123)
115 | ->withheldIss(123)
116 | ->cityCode(123)
117 | ->aliquotas()
118 | ->cofins(1.0)
119 | ->csll(0.10)
120 | ->inss(2.01)
121 | ->ir(1.05)
122 | ->pis(0.5)
123 | ->iss(0.08)
124 | ->save()
125 | ->make()
126 | ;
127 | ```
128 | # Obs:
129 | No momento só foi implementado emissão de notafiscal NF-e / NFS-e
130 | TODO: Criar consulta a notas por código e filtros
131 |
132 |
--------------------------------------------------------------------------------
/check-standards:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ./vendor/bin/phpcs --colors --standard=psr12 ./src/Multiverse
4 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "multiverse/notazzsdk",
3 | "description": "Notazz SDK api para integração com Notazz",
4 | "type": "library",
5 | "license": "MIT",
6 | "authors": [
7 | {
8 | "name": "Leonardo Tumadjian",
9 | "email": "tumadjian@gmail.com"
10 | }
11 | ],
12 | "autoload": {
13 | "psr-4": {
14 | "Multiverse\\" : "src/Multiverse"
15 | }
16 | },
17 | "require": {
18 | "php": "^7.2.0 || ^8.0.0",
19 | "guzzlehttp/guzzle": "^6.3"
20 | },
21 | "require-dev": {
22 | "phpunit/phpunit": "^8.0",
23 | "squizlabs/php_codesniffer": "^3.4"
24 | },
25 | "scripts": {
26 | "test": "phpunit tests",
27 | "check-standards": "phpcs --colors --standard=PSR12 src",
28 | "fix-standards": "phpcbf --colors --standard=PSR12 src"
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/fix-to-psr12:
--------------------------------------------------------------------------------
1 | vendor/bin/phpcbf --standard=psr12 src/
2 |
--------------------------------------------------------------------------------
/phpunit.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
14 | tests
15 |
16 |
17 |
18 |
19 | src/
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/run-test:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ./vendor/bin/phpunit --colors=always tests
4 |
--------------------------------------------------------------------------------
/src/Multiverse/Notazz/DSL/AliquotasBuilder.php:
--------------------------------------------------------------------------------
1 | aliquotas = new Aliquotas();
16 | }
17 |
18 | public function __call(string $method, array $args)
19 | {
20 | $method = ucfirst(Formatter::snakeToCamel($method));
21 |
22 | $method = 'set' . $method;
23 |
24 | if (false === method_exists($this->aliquotas, $method)) {
25 | throw new MethodNotFoundException("Method ($method) not found in class " . get_class($this->aliquotas));
26 | }
27 |
28 | $this->aliquotas->$method($args[0]);
29 | return $this;
30 | }
31 |
32 | public function getInstance(): Aliquotas
33 | {
34 | return $this->aliquotas;
35 | }
36 |
37 | public function getArray(): array
38 | {
39 | return $this->aliquotas->toArray();
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/Multiverse/Notazz/DSL/DestinationBuilder.php:
--------------------------------------------------------------------------------
1 | destination = new Destination();
21 | }
22 |
23 | public function __call(string $method, array $args)
24 | {
25 | $method = ucfirst(Formatter::snakeToCamel($method));
26 |
27 | $method = "setDestination$method";
28 |
29 | if (false === method_exists($this->destination, $method)) {
30 | throw new MethodNotFoundException("Method ($method) not found in class " . get_class($this->destination));
31 | }
32 |
33 | $this->lastCalled = $method;
34 |
35 | $this->destination->$method($args[0]);
36 | return $this;
37 | }
38 |
39 | public function getArray()
40 | {
41 | return $this->destination->toArray();
42 | }
43 |
44 | public function sendEmailList()
45 | {
46 | $this->lastCalled = 'sendEmailList';
47 | return $this;
48 | }
49 |
50 | public function add($email)
51 | {
52 | if ($this->lastCalled != 'sendEmailList') {
53 | throw new CantAddEmailException('Cannot add email after a method diferent from sendEmailList');
54 | }
55 | $this->emailList[] = $email;
56 | return $this;
57 | }
58 |
59 | public function end()
60 | {
61 | $this->emailSend($this->emailList);
62 | $this->emailList = [];
63 | $this->lastCalled = false;
64 | return $this;
65 | }
66 |
67 | public function getInstance()
68 | {
69 | return $this->destination;
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/src/Multiverse/Notazz/DSL/DocumentBuilder.php:
--------------------------------------------------------------------------------
1 | document = new NFeDocument();
23 | $this->setDocumentType(self::NFE);
24 | return $this;
25 | }
26 |
27 | public function nfse()
28 | {
29 | $this->document = new NFSeDocument();
30 | $this->setDocumentType(self::NFSE);
31 | return $this;
32 | }
33 |
34 | public function getDocumentType(): int
35 | {
36 | return $this->documentType;
37 | }
38 |
39 | public function setDocumentType(int $documentType): void
40 | {
41 | $this->documentType = $documentType;
42 | }
43 |
44 | public function __call(string $method, array $args)
45 | {
46 | $method = ucfirst(Formatter::snakeToCamel($method));
47 |
48 | $method = "setDocument$method";
49 |
50 | if (false === method_exists($this->document, $method)) {
51 | throw new MethodNotFoundException("Method ($method) not found in class " . get_class($this->document));
52 | }
53 |
54 | $this->document->$method($args[0]);
55 | return $this;
56 | }
57 |
58 | public function getArray()
59 | {
60 | return $this->document->toArray();
61 | }
62 |
63 | public function getInstance()
64 | {
65 | return $this->document;
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/Multiverse/Notazz/DSL/Exceptions/CantAddEmailException.php:
--------------------------------------------------------------------------------
1 | handler = new Client();
33 |
34 | $this->destination = new DestinationBuilder();
35 | $this->document = new DocumentBuilder();
36 | $this->products = new ProductsBuilder();
37 | $this->service = new ServiceBuilder();
38 | $this->shipping = new ShippingBuilder();
39 | }
40 |
41 | public function setRequestHandler($handler)
42 | {
43 | $this->handler = $handler;
44 | return $this;
45 | }
46 |
47 | public function key(string $apiKey)
48 | {
49 | $this->apiKey = $apiKey;
50 | return $this;
51 | }
52 |
53 | public function __call($method, $args)
54 | {
55 | $arg = $args[0] ?? null;
56 |
57 | $target = $this->current;
58 |
59 | $this->$target->$method($arg);
60 |
61 | return $this;
62 | }
63 |
64 | public function destination()
65 | {
66 | $this->current = 'destination';
67 | return $this;
68 | }
69 |
70 | public function document()
71 | {
72 | $this->current = 'document';
73 | return $this;
74 | }
75 |
76 | public function products()
77 | {
78 | $this->current = 'products';
79 | return $this;
80 | }
81 |
82 | public function service()
83 | {
84 | $this->current = 'service';
85 | return $this;
86 | }
87 |
88 | public function shipping()
89 | {
90 | $this->current = 'shipping';
91 | return $this;
92 | }
93 |
94 | public function isNFE(): bool
95 | {
96 | return (bool)$this->document->getDocumentType();
97 | }
98 |
99 | protected function getNFObject()
100 | {
101 | if ($this->isNFE()) {
102 | return new NFe(
103 | $this->destination->getInstance(),
104 | $this->document->getInstance(),
105 | $this->products->getInstance(),
106 | $this->shipping->getInstance()
107 | );
108 | }
109 | return new NFSe(
110 | $this->destination->getInstance(),
111 | $this->document->getInstance(),
112 | $this->service->getInstance()
113 | );
114 | }
115 |
116 | public function make()
117 | {
118 | $nf = $this->getNFObject();
119 |
120 | $notafiscal = new NotaFiscal($this->apiKey, $nf);
121 |
122 | $notafiscal->setHandler($this->handler);
123 |
124 | return $notafiscal->create();
125 | }
126 |
127 | public function getJson()
128 | {
129 | $nf = $this->getNFObject();
130 | $notafiscal = new NotaFiscal($this->apiKey, $nf);
131 |
132 | return $notafiscal->prepareRequest();
133 | }
134 | }
135 |
--------------------------------------------------------------------------------
/src/Multiverse/Notazz/DSL/ProductsBuilder.php:
--------------------------------------------------------------------------------
1 | products = new Products();
21 | }
22 |
23 | public function __call(string $method, array $args)
24 | {
25 | $this->productItem = $this->makeProductItemInstance();
26 |
27 | $method = ucfirst(Formatter::snakeToCamel($method));
28 |
29 | $method = "setDocumentProduct$method";
30 |
31 | if (false === method_exists($this->productItem, $method)) {
32 | throw new MethodNotFoundException("Method ($method) not found in class " . get_class($this->productItem));
33 | }
34 |
35 | $this->productItem->$method($args[0]);
36 |
37 | $this->setAdding(true);
38 |
39 | return $this;
40 | }
41 |
42 | public function add()
43 | {
44 | $this->setAdding(true);
45 | return $this;
46 | }
47 |
48 | public function save()
49 | {
50 | $this->setAdding(false);
51 | $this->products->addItem($this->productItem);
52 | $this->productItem = null;
53 | return $this;
54 | }
55 |
56 | public function getArray()
57 | {
58 | return $this->products->toArray();
59 | }
60 |
61 | protected function setAdding(bool $adding)
62 | {
63 | $this->adding = $adding;
64 | }
65 |
66 | protected function isAdding(): bool
67 | {
68 | return $this->adding;
69 | }
70 |
71 | protected function makeProductItemInstance(): ProductItem
72 | {
73 | if ($this->productItem instanceof ProductItem) {
74 | return $this->productItem;
75 | }
76 | return new ProductItem();
77 | }
78 |
79 | public function getInstance()
80 | {
81 | return $this->products;
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/src/Multiverse/Notazz/DSL/ServiceBuilder.php:
--------------------------------------------------------------------------------
1 | service = new Service();
18 | $this->aliquotasBuilder = new AliquotasBuilder();
19 | }
20 |
21 | public function __call(string $method, array $args)
22 | {
23 | $arg = $args[0] ?? null;
24 | $this->aliquotasBuilder->$method($arg);
25 | return $this;
26 | }
27 |
28 | public function listLc116($value)
29 | {
30 | $this->service->setServiceListLc116($value);
31 | return $this;
32 | }
33 |
34 | public function withheldIss($value)
35 | {
36 | $this->service->setWithheldIss($value);
37 | return $this;
38 | }
39 |
40 | public function cityCode($value)
41 | {
42 | $this->service->setCityServiceCode($value);
43 | return $this;
44 | }
45 |
46 | public function description($value)
47 | {
48 | $this->service->setCityServiceDescription($value);
49 | return $this;
50 | }
51 |
52 | public function aliquotas()
53 | {
54 | return $this;
55 | }
56 |
57 | public function save()
58 | {
59 | $this->service->setAliquotas($this->aliquotasBuilder->getInstance());
60 | return $this;
61 | }
62 |
63 | public function getArray(): array
64 | {
65 | return $this->service->toArray();
66 | }
67 |
68 | public function getInstance(): Service
69 | {
70 | return $this->service;
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/src/Multiverse/Notazz/DSL/ShippingBuilder.php:
--------------------------------------------------------------------------------
1 | shipping = new Shipping();
25 |
26 | $this->shippingCarrierBuilder = new ShippingCarrierBuilder();
27 | $this->shippingVehiclesBuilder = new ShippingVehiclesBuilder();
28 | $this->shippingVolumesBuilder = new ShippingVolumesBuilder();
29 | }
30 |
31 | public function __call($method, $args)
32 | {
33 | $arg = $args[0] ?? null;
34 |
35 | $target = $this->current;
36 |
37 | $this->$target->$method($arg);
38 |
39 | return $this;
40 | }
41 |
42 | public function value($value)
43 | {
44 | $this->shipping->setDocumentFreteValue($value);
45 |
46 | return $this;
47 | }
48 |
49 | public function mode($value)
50 | {
51 | $this->shipping->setDocumentFreteMod($value);
52 |
53 | return $this;
54 | }
55 |
56 | public function carrier()
57 | {
58 | $this->current = 'shippingCarrierBuilder';
59 |
60 | return $this;
61 | }
62 |
63 | public function vehicles()
64 | {
65 | $this->current = 'shippingVehiclesBuilder';
66 |
67 | return $this;
68 | }
69 |
70 | public function volumes()
71 | {
72 | $this->current = 'shippingVolumesBuilder';
73 |
74 | return $this;
75 | }
76 |
77 | public function save()
78 | {
79 | $this->shipping->setDocumentFreteTransportadora(
80 | $this->shippingCarrierBuilder->getInstance()
81 | );
82 |
83 | $this->shipping->setDocumentFreteVeiculo(
84 | $this->shippingVehiclesBuilder->getInstance()
85 | );
86 |
87 | $this->shipping->setDocumentFreteVolumes(
88 | $this->shippingVolumesBuilder->getInstance()
89 | );
90 |
91 | return $this;
92 | }
93 |
94 | public function getArray()
95 | {
96 | return $this->shipping->toArray();
97 | }
98 |
99 | public function getInstance()
100 | {
101 | return $this->shipping;
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/src/Multiverse/Notazz/DSL/ShippingCarrierBuilder.php:
--------------------------------------------------------------------------------
1 | shippingCarrier = new ShippingCarrier();
16 | }
17 |
18 | public function __call(string $method, array $args)
19 | {
20 | $method = ucfirst(Formatter::snakeToCamel($method));
21 |
22 | $method = "setDocumentFreteTransportadora$method";
23 |
24 | if (false === method_exists($this->shippingCarrier, $method)) {
25 | throw new MethodNotFoundException(
26 | "Method ($method) not found in class " . get_class($this->shippingCarrier)
27 | );
28 | }
29 |
30 | $this->shippingCarrier->$method($args[0]);
31 | return $this;
32 | }
33 |
34 | public function getArray()
35 | {
36 | return $this->shippingCarrier->toArray();
37 | }
38 |
39 | public function getInstance()
40 | {
41 | return $this->shippingCarrier;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/Multiverse/Notazz/DSL/ShippingVehiclesBuilder.php:
--------------------------------------------------------------------------------
1 | shippingVehicles = new ShippingVehicles();
16 | }
17 |
18 | public function __call(string $method, array $args)
19 | {
20 | $method = ucfirst(Formatter::snakeToCamel($method));
21 |
22 | $method = "setDocumentFreteVeiculo$method";
23 |
24 | if (false === method_exists($this->shippingVehicles, $method)) {
25 | throw new MethodNotFoundException(
26 | "Method ($method) not found in class " . get_class($this->shippingVehicles)
27 | );
28 | }
29 |
30 | $this->shippingVehicles->$method($args[0]);
31 | return $this;
32 | }
33 |
34 | public function getArray()
35 | {
36 | return $this->shippingVehicles->toArray();
37 | }
38 |
39 | public function getInstance()
40 | {
41 | return $this->shippingVehicles;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/Multiverse/Notazz/DSL/ShippingVolumesBuilder.php:
--------------------------------------------------------------------------------
1 | shippingVolumes = new ShippingVolumes();
16 | }
17 |
18 | public function __call(string $method, array $args)
19 | {
20 | $method = ucfirst(Formatter::snakeToCamel($method));
21 |
22 | $method = "setDocumentFreteVolumes$method";
23 |
24 | if (false === method_exists($this->shippingVolumes, $method)) {
25 | throw new MethodNotFoundException(
26 | "Method ($method) not found in class " . get_class($this->shippingVolumes)
27 | );
28 | }
29 |
30 | $this->shippingVolumes->$method($args[0]);
31 | return $this;
32 | }
33 |
34 | public function getArray()
35 | {
36 | return $this->shippingVolumes->toArray();
37 | }
38 |
39 | public function getInstance()
40 | {
41 | return $this->shippingVolumes;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/Multiverse/Notazz/DSL/Tools/Formatter.php:
--------------------------------------------------------------------------------
1 | destination_name;
76 | }
77 |
78 | /**
79 | * Set the value of DESTINATION_NAME
80 | *
81 | * @param string $destination_name
82 | */
83 | public function setDestinationName(string $destination_name)
84 | {
85 | $this->destination_name = $destination_name;
86 | }
87 |
88 | /**
89 | * Get the value of DESTINATION_TAXID
90 | *
91 | * @return int
92 | */
93 | public function getDestinationTaxid()
94 | {
95 | return $this->destination_taxid;
96 | }
97 |
98 | /**
99 | * Set the value of DESTINATION_TAXID
100 | * CPF ou CNPJ
101 | *
102 | * @param int $destination_taxid
103 | */
104 | public function setDestinationTaxid(string $destination_taxid)
105 | {
106 | $this->destination_taxid = $destination_taxid;
107 | }
108 |
109 | /**
110 | * Get the value of DESTINATION_IE
111 | *
112 | * @return string
113 | */
114 | public function getDestinationIe()
115 | {
116 | return $this->destination_ie;
117 | }
118 |
119 | /**
120 | * Set the value of DESTINATION_IE
121 | * Inscrição Estadual
122 | *
123 | * @param string $destination_ie
124 | */
125 | public function setDestinationIe(string $destination_ie)
126 | {
127 | $this->destination_ie = $destination_ie;
128 | }
129 |
130 | /**
131 | * Get the value of DESTINATION_IM
132 | *
133 | * @return string
134 | */
135 | public function getDestinationIm()
136 | {
137 | return $this->destination_im;
138 | }
139 |
140 | /**
141 | * Set the value of DESTINATION_IM
142 | * Inscrição Municipal
143 | *
144 | * @param string $destination_im
145 | */
146 | public function setDestinationIm(string $destination_im)
147 | {
148 | $this->destination_im = $destination_im;
149 | }
150 |
151 | /**
152 | * Get the value of DESTINATION_TAXTYPE
153 | *
154 | * @return string
155 | */
156 | public function getDestinationTaxtype()
157 | {
158 | return $this->destination_taxtype;
159 | }
160 |
161 | /**
162 | * Set the value of DESTINATION_TAXTYPE
163 | * F = Física, J = Jurídica, E = Estrangeiro
164 | *
165 | * @param string $destination_taxtype
166 | */
167 | public function setDestinationTaxtype(string $destination_taxtype)
168 | {
169 | $this->destination_taxtype = $destination_taxtype;
170 | }
171 |
172 | /**
173 | * Get the value of DESTINATION_STREET
174 | *
175 | * @return string
176 | */
177 | public function getDestinationStreet()
178 | {
179 | return $this->destination_street;
180 | }
181 |
182 | /**
183 | * Set the value of DESTINATION_STREET
184 | * Logradouro
185 | *
186 | * @param string $destination_street
187 | */
188 | public function setDestinationStreet(string $destination_street)
189 | {
190 | $this->destination_street = $destination_street;
191 | }
192 |
193 | /**
194 | * Get the value of DESTINATION_NUMBER
195 | *
196 | * @return string
197 | */
198 | public function getDestinationNumber()
199 | {
200 | return $this->destination_number;
201 | }
202 |
203 | /**
204 | * Set the value of DESTINATION_NUMBER
205 | *
206 | * @param string $destination_number
207 | */
208 | public function setDestinationNumber(string $destination_number)
209 | {
210 | $this->destination_number = $destination_number;
211 | }
212 |
213 | /**
214 | * Get the value of DESTINATION_COMPLEMENT
215 | *
216 | * @return string
217 | */
218 | public function getDestinationComplement()
219 | {
220 | return $this->destination_complement;
221 | }
222 |
223 | /**
224 | * Set the value of DESTINATION_COMPLEMENT
225 | *
226 | * @param string $destination_complement
227 | */
228 | public function setDestinationComplement(string $destination_complement)
229 | {
230 | $this->destination_complement = $destination_complement;
231 | }
232 |
233 | /**
234 | * Get the value of DESTINATION_DISTRICT
235 | *
236 | * @return string
237 | */
238 | public function getDestinationDistrict()
239 | {
240 | return $this->destination_district;
241 | }
242 |
243 | /**
244 | * Set the value of DESTINATION_DISTRICT
245 | * Bairro
246 | *
247 | * @param string $destination_district
248 | */
249 | public function setDestinationDistrict(string $destination_district)
250 | {
251 | $this->destination_district = $destination_district;
252 | }
253 |
254 | /**
255 | * Get the value of DESTINATION_CITY
256 | *
257 | * @return string
258 | */
259 | public function getDestinationCity()
260 | {
261 | return $this->destination_city;
262 | }
263 |
264 | /**
265 | * Set the value of DESTINATION_CITY
266 | * Cidade
267 | *
268 | * @param string $destination_city
269 | */
270 | public function setDestinationCity(string $destination_city)
271 | {
272 | $this->destination_city = $destination_city;
273 | }
274 |
275 | /**
276 | * Get the value of DESTINATION_UF
277 | *
278 | * @return int
279 | */
280 | public function getDestinationUf()
281 | {
282 | return $this->destination_uf;
283 | }
284 |
285 | /**
286 | * Set the value of DESTINATION_UF
287 | *
288 | * @param int $destination_uf
289 | */
290 | public function setDestinationUf(string $destination_uf)
291 | {
292 | $this->destination_uf = $destination_uf;
293 | }
294 |
295 | /**
296 | * Get the value of DESTINATION_ZIPCODE
297 | *
298 | * @return string
299 | */
300 | public function getDestinationZipcode()
301 | {
302 | return $this->destination_zipcode;
303 | }
304 |
305 | /**
306 | * Set the value of DESTINATION_ZIPCODE
307 | * CEP
308 | *
309 | * @param string $destination_zipcode
310 | */
311 | public function setDestinationZipcode(string $destination_zipcode)
312 | {
313 | $this->destination_zipcode = $destination_zipcode;
314 | }
315 |
316 | /**
317 | * Get the value of DESTINATION_PHONE
318 | *
319 | * @return int
320 | */
321 | public function getDestinationPhone()
322 | {
323 | return $this->destination_phone;
324 | }
325 |
326 | /**
327 | * Set the value of DESTINATION_PHONE
328 | *
329 | * @param int $destination_phone
330 | */
331 | public function setDestinationPhone(string $destination_phone)
332 | {
333 | $this->destination_phone = $destination_phone;
334 | }
335 |
336 | /**
337 | * Get the value of DESTINATION_EMAIL
338 | *
339 | * @return string
340 | */
341 | public function getDestinationEmail()
342 | {
343 | return $this->destination_email;
344 | }
345 |
346 | /**
347 | * Set the value of DESTINATION_EMAIL
348 | *
349 | * @param string $destination_email
350 | */
351 | public function setDestinationEmail(string $destination_email)
352 | {
353 | $this->destination_email = $destination_email;
354 | }
355 |
356 | /**
357 | * Get the value of DESTINATION_EMAIL_SEND
358 | * Esse parâmetro é um Array que irá conter os e-mails que será enviado após a nota ser autorizada ou cancelada.
359 | * OBS: Para cada e-mail que será enviado, passe os parâmetros abaixo alterando o índice em +1 para cada e-mail
360 | *
361 | * @return array
362 | */
363 | public function getDestinationEmailSend()
364 | {
365 | return $this->destination_email_send;
366 | }
367 |
368 | /**
369 | * Set the value of DESTINATION_EMAIL_SEND
370 | * Esse parâmetro é um Array que irá conter os e-mails que será enviado após a nota ser autorizada ou cancelada.
371 | * OBS: Para cada e-mail que será enviado, passe os parâmetros abaixo alterando o índice em +1 para cada e-mail
372 | *
373 | * @param array $destination_email_send
374 | */
375 | public function setDestinationEmailSend(array $destination_email_send)
376 | {
377 | $this->destination_email_send = $destination_email_send;
378 | }
379 | }
380 |
--------------------------------------------------------------------------------
/src/Multiverse/Notazz/Exceptions/ErrorStatusProcessamentoException.php:
--------------------------------------------------------------------------------
1 | destination = $destination;
35 | $this->document = $document;
36 | $this->service = $service;
37 | }
38 |
39 | /**
40 | * Monta a estruta da NFS-e
41 | *
42 | * @return array
43 | */
44 | public function mount(): array
45 | {
46 | if ($this->service === null) {
47 | return array_merge(
48 | $this->document->toArray(),
49 | $this->destination->toArray()
50 | );
51 | }
52 |
53 | return array_merge(
54 | $this->document->toArray(),
55 | $this->service->toArray(),
56 | $this->destination->toArray()
57 | );
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/src/Multiverse/Notazz/NFSe/Aliquotas.php:
--------------------------------------------------------------------------------
1 | cofins = $cofins;
51 | $this->csll = $csll;
52 | $this->inss = $inss;
53 | $this->ir = $ir;
54 | $this->pis = $pis;
55 | $this->iss = $iss;
56 | }
57 | /**
58 | * Get The value of cofins
59 | *
60 | * @return float
61 | */
62 | public function getCofins()
63 | {
64 | return $this->cofins;
65 | }
66 |
67 | /**
68 | * set the value of cofins
69 | *
70 | * @param float $cofins
71 | */
72 | public function setCofins(float $cofins)
73 | {
74 | $this->cofins = $cofins;
75 | }
76 |
77 | /**
78 | * Get The value of csll
79 | *
80 | * @return float
81 | */
82 | public function getCsll()
83 | {
84 | return $this->csll;
85 | }
86 |
87 | /**
88 | * set the value of csll
89 | *
90 | * @param float $csll
91 | */
92 | public function setCsll(float $csll)
93 | {
94 | $this->csll = $csll;
95 | }
96 |
97 | /**
98 | * Get The value of inss
99 | *
100 | * @return float
101 | */
102 | public function getInss()
103 | {
104 | return $this->inss;
105 | }
106 |
107 | /**
108 | * set the value of inss
109 | *
110 | * @param float $inss
111 | */
112 | public function setInss(float $inss)
113 | {
114 | $this->INSS = $inss;
115 | }
116 |
117 | /**
118 | * Get The value of ir
119 | *
120 | * @return float
121 | */
122 | public function getIr()
123 | {
124 | return $this->ir;
125 | }
126 |
127 | /**
128 | * set the value of ir
129 | *
130 | * @param float $ir
131 | */
132 | public function setIr(float $ir)
133 | {
134 | $this->ir = $ir;
135 | }
136 |
137 | /**
138 | * Get The value of pis
139 | *
140 | * @return float
141 | */
142 | public function getPis()
143 | {
144 | return $this->pis;
145 | }
146 |
147 | /**
148 | * set the value of pis
149 | *
150 | * @param float $pis
151 | */
152 | public function setPis(float $pis)
153 | {
154 | $this->pis = $pis;
155 | }
156 |
157 | /**
158 | * Get The value of iss
159 | *
160 | * @return float
161 | */
162 | public function getIss()
163 | {
164 | return $this->iss;
165 | }
166 |
167 | /**
168 | * set the value of iss
169 | *
170 | * @param float $iss
171 | */
172 | public function setIss(float $iss)
173 | {
174 | $this->iss = $iss;
175 | }
176 | }
177 |
--------------------------------------------------------------------------------
/src/Multiverse/Notazz/NFSe/Document.php:
--------------------------------------------------------------------------------
1 | setDocumentIssueDate($currentDate);
34 | $this->setDocumentCompetence($currentDate);
35 | }
36 |
37 | /**
38 | * Get the value of DOCUMENT_BASEVALUE
39 | *
40 | * @return float
41 | */
42 | public function getDocumentBasevalue()
43 | {
44 | return $this->document_basevalue;
45 | }
46 |
47 | /**
48 | * Valor da nota fiscal
49 | *
50 | * @param float $document_basevalue
51 | */
52 | public function setDocumentBasevalue(float $document_basevalue)
53 | {
54 | $this->document_basevalue = $document_basevalue;
55 | }
56 |
57 | /**
58 | * Get the value of DOCUMENT_DESCRIPTION
59 | *
60 | * @return string
61 | */
62 | public function getDocumentDescription()
63 | {
64 | return $this->document_description;
65 | }
66 |
67 | /**
68 | * Descrição da nota fiscal
69 | *
70 | * @param string $document_description
71 | */
72 | public function setDocumentDescription(string $document_description)
73 | {
74 | $this->document_description = $document_description;
75 | }
76 |
77 | /**
78 | * Get the value of DOCUMENT_COMPETENCE
79 | *
80 | * @return string
81 | */
82 | public function getDocumentCompetence()
83 | {
84 | return $this->document_competence;
85 | }
86 |
87 | /**
88 | * Competência. Utilizar padrão: YYYY-mm-dd
89 | *
90 | * @param string $document_competence
91 | */
92 | public function setDocumentCompetence(string $document_competence)
93 | {
94 | $this->document_competence = $document_competence;
95 | }
96 |
97 | /**
98 | * Get the value of DOCUMENT_CNAE
99 | *
100 | * @return int
101 | */
102 | public function getDocumentCnae()
103 | {
104 | return $this->document_cnae;
105 | }
106 |
107 | /**
108 | * CNAE. Documentação: http://www.cnae.ibge.gov.br
109 | *
110 | * @param int $document_cnae
111 | */
112 | public function setDocumentCnae(int $document_cnae)
113 | {
114 | $this->document_cnae = $document_cnae;
115 | }
116 |
117 | /**
118 | * Get the value of DOCUMENT_ISSUE_DATE
119 | *
120 | * @return string
121 | */
122 | public function getDocumentIssueDate()
123 | {
124 | return $this->document_issue_date;
125 | }
126 |
127 | /**
128 | * Data de emissão automática da nota fiscal (por padrão é a data atual) formato YYYY-mm-dd HH:ii:ss
129 | *
130 | * @param string $document_issue_date
131 | */
132 | public function setDocumentIssueDate(string $document_issue_date)
133 | {
134 | $this->document_issue_date = $document_issue_date;
135 | }
136 | }
137 |
--------------------------------------------------------------------------------
/src/Multiverse/Notazz/NFSe/Service.php:
--------------------------------------------------------------------------------
1 | service_list_lc116;
38 | }
39 |
40 | /**
41 | * Item da Lista de Serviço da lc 116.
42 | * Ex: 17.06
43 | *
44 | * @param int $service_list_lc116
45 | */
46 | public function setServiceListLc116(float $service_list_lc116)
47 | {
48 | $this->service_list_lc116 = $service_list_lc116;
49 | }
50 |
51 | /**
52 | * Get The value of withheld_iss
53 | *
54 | * @return int
55 | */
56 | public function getWithheldIss()
57 | {
58 | return $this->withheld_iss;
59 | }
60 |
61 | /**
62 | * ISS retido na fonte. 1 = Retido e 0 = Não retido.
63 | *
64 | * @param int $withheld_iss
65 | */
66 | public function setWithheldIss(int $withheld_iss)
67 | {
68 | $this->withheld_iss = $withheld_iss;
69 | }
70 |
71 | /**
72 | * getThe value of city_service_code
73 | *
74 | * @return int
75 | */
76 | public function getCityServiceCode()
77 | {
78 | return $this->city_service_code;
79 | }
80 |
81 | /**
82 | * Código de serviço do município
83 | *
84 | * @param int $city_service_code
85 | */
86 | public function setCityServiceCode(int $city_service_code)
87 | {
88 | $this->city_service_code = $city_service_code;
89 | }
90 |
91 | /**
92 | * getThe value of city_service_description
93 | *
94 | * @return string
95 | */
96 | public function getCityServiceDescription()
97 | {
98 | return $this->city_service_description;
99 | }
100 |
101 | /**
102 | * Descrição do serviço do município
103 | *
104 | * @param string $city_service_description
105 | */
106 | public function setCityServiceDescription(string $city_service_description)
107 | {
108 | $this->city_service_description = $city_service_description;
109 | }
110 |
111 | /**
112 | * getThe value of aliquotas
113 | *
114 | * @return array
115 | */
116 | public function getAliquotas()
117 | {
118 | return $this->aliquotas;
119 | }
120 |
121 | /**
122 | * Set the value of aliquotas
123 | *
124 | * @param array $aliquotas
125 | */
126 | public function setAliquotas(Aliquotas $aliquotas)
127 | {
128 | $this->aliquotas = $aliquotas->toArray();
129 | }
130 | }
131 |
--------------------------------------------------------------------------------
/src/Multiverse/Notazz/NFe.php:
--------------------------------------------------------------------------------
1 | document = $document;
42 | $this->destination = $destination;
43 | $this->products = $products;
44 | $this->shipping = $shipping;
45 | }
46 |
47 | /**
48 | * @return array
49 | */
50 | public function mount(): array
51 | {
52 | if (false === $this->hasShipping()) {
53 | return array_merge(
54 | $this->document->toArray(),
55 | $this->destination->toArray(),
56 | $this->products->toArray()
57 | );
58 | }
59 |
60 | return array_merge(
61 | $this->document->toArray(),
62 | $this->destination->toArray(),
63 | $this->products->toArray(),
64 | $this->shipping->toArray()
65 | );
66 | }
67 |
68 | /**
69 | * @return bool
70 | */
71 | protected function hasShipping()
72 | {
73 | if ($this->shipping === null) {
74 | return false;
75 | }
76 |
77 | $frete = $this->shipping->toArray();
78 |
79 | if (count($frete['DOCUMENT_FRETE']) === 0) {
80 | return false;
81 | }
82 |
83 | return true;
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/src/Multiverse/Notazz/NFe/Document.php:
--------------------------------------------------------------------------------
1 | setDocumentIssueDate($date);
47 | }
48 |
49 | /**
50 | *
51 | * @return float
52 | */
53 | public function getDocumentBasevalue()
54 | {
55 | return $this->document_basevalue;
56 | }
57 |
58 | /**
59 | * Valor da nota fiscal
60 | *
61 | * @param float $document_basevalue
62 | */
63 | public function setDocumentBasevalue(float $document_basevalue)
64 | {
65 | $this->document_basevalue = $document_basevalue;
66 | }
67 |
68 | /**
69 | * Get the value of DOCUMENT_CNAE
70 | *
71 | * @return int
72 | */
73 | public function getDocumentCnae()
74 | {
75 | return $this->document_cnae;
76 | }
77 |
78 | /**
79 | * CNAE. Documentação: http://www.cnae.ibge.gov.br
80 | *
81 | * @param int $document_cnae
82 | *
83 | * @return self
84 | */
85 | public function setDocumentCnae(int $document_cnae)
86 | {
87 | $this->document_cnae = $document_cnae;
88 |
89 | return $this;
90 | }
91 |
92 | /**
93 | * Get the value of DOCUMENT_GOAL
94 | *
95 | * @return int
96 | */
97 | public function getDocumentGoal()
98 | {
99 | return $this->document_goal;
100 | }
101 |
102 | /**
103 | * Finalidade da Nota Fiscal. 1 = Normal, 2 = Complementar, 3 = Ajuste, 4 = Devolução/Retorno
104 | *
105 | * @param int $document_goal
106 | */
107 | public function setDocumentGoal(int $document_goal)
108 | {
109 | $this->document_goal = $document_goal;
110 | }
111 |
112 | /**
113 | * Get the value of DOCUMENT_REFERENCED
114 | *
115 | * @return int
116 | */
117 | public function getDocumentReferenced()
118 | {
119 | return $this->document_referenced;
120 | }
121 |
122 | /**
123 | * Chave da nota fiscal referenciada. Utilizar quando DOCUMENT_GOAL for diferente de 1
124 | *
125 | * @param int $document_referenced
126 | */
127 | public function setDocumentReferenced(int $document_referenced)
128 | {
129 | $this->document_referenced = $document_referenced;
130 | }
131 |
132 | /**
133 | * Get the value of DOCUMENT_OPERATION_TYPE
134 | *
135 | * @return int
136 | */
137 | public function getDocumentOperationType()
138 | {
139 | return $this->document_operation_type;
140 | }
141 |
142 | /**
143 | * Tipo de Operação. 0 = Entrada, 1 = Saída
144 | *
145 | * @param int $document_operation_type
146 | */
147 | public function setDocumentOperationType(int $document_operation_type)
148 | {
149 | $this->document_operation_type = $document_operation_type;
150 | }
151 |
152 | /**
153 | * Get the value of DOCUMENT_NATURE_OPERATION
154 | *
155 | * @return string
156 | */
157 | public function getDocumentNatureOperation()
158 | {
159 | return $this->document_nature_operation;
160 | }
161 |
162 | /**
163 | * Natureza da operação da nota fiscal
164 | *
165 | * @param string $document_nature_operation
166 | */
167 | public function setDocumentNatureOperation(string $document_nature_operation)
168 | {
169 | $this->document_nature_operation = $document_nature_operation;
170 | }
171 |
172 | /**
173 | * Get the value of DOCUMENT_DESCRIPTION
174 | *
175 | * @return string
176 | */
177 | public function getDocumentDescription()
178 | {
179 | return $this->document_description;
180 | }
181 |
182 | /**
183 | * Descrição da nota fiscal
184 | *
185 | * @param string $document_description
186 | */
187 | public function setDocumentDescription(string $document_description)
188 | {
189 | $this->document_description = $document_description;
190 | }
191 |
192 | /**
193 | * Get the value of DOCUMENT_ISSUE_DATE
194 | *
195 | * @return string
196 | */
197 | public function getDocumentIssueDate()
198 | {
199 | return $this->document_issue_date;
200 | }
201 |
202 | /**
203 | * Data de emissão automática da nota fiscal (por padrão é a data atual) formato YYYY-mm-dd HH:ii:ss
204 | *
205 | * @param string $document_issue_date
206 | */
207 | public function setDocumentIssueDate(string $document_issue_date)
208 | {
209 | $this->document_issue_date = $document_issue_date;
210 | }
211 | }
212 |
--------------------------------------------------------------------------------
/src/Multiverse/Notazz/NFe/ProductItem.php:
--------------------------------------------------------------------------------
1 | document_product_cod = $cod;
82 | $this->document_product_name = $name;
83 | $this->document_product_qtd = $qtd;
84 | $this->document_product_unitary_value = $unitaryValue;
85 | }
86 |
87 | /**
88 | * Get the value of DOCUMENT_PRODUCT_COD
89 | *
90 | * @return int
91 | */
92 | public function getDocumentProductCod()
93 | {
94 | return $this->document_product_cod;
95 | }
96 |
97 | /**
98 | * Cód do produto
99 | *
100 | * @param int $document_product_cod
101 | */
102 | public function setDocumentProductCod(int $document_product_cod)
103 | {
104 | $this->document_product_cod = $document_product_cod;
105 | }
106 |
107 | /**
108 | * Get the value of DOCUMENT_PRODUCT_TAX_COD
109 | *
110 | * @return int
111 | */
112 | public function getDocumentProductTaxCod()
113 | {
114 | return $this->document_product_tax_cod;
115 | }
116 |
117 | /**
118 | * Cód fiscal do produto (código da logística)
119 | *
120 | * @param int $document_product_tax_cod
121 | */
122 | public function setDocumentProductTaxCod(int $document_product_tax_cod)
123 | {
124 | $this->document_product_tax_cod = $document_product_tax_cod;
125 | }
126 |
127 | /**
128 | * Get the value of DOCUMENT_PRODUCT_EAN
129 | *
130 | * @return string
131 | */
132 | public function getDocumentProductEan()
133 | {
134 | return $this->document_product_ean;
135 | }
136 |
137 | /**
138 | * Código de barras
139 | *
140 | * @param mixed $document_product_ean
141 | */
142 | public function setDocumentProductEan($document_product_ean)
143 | {
144 | $this->document_product_ean = $document_product_ean;
145 | }
146 |
147 | /**
148 | * Get the value of DOCUMENT_PRODUCT_NAME
149 | *
150 | * @return string
151 | */
152 | public function getDocumentProductName()
153 | {
154 | return $this->document_product_name;
155 | }
156 |
157 | /**
158 | * Nome do produto
159 | *
160 | * @param string $document_product_name
161 | */
162 | public function setDocumentProductName(string $document_product_name)
163 | {
164 | $this->document_product_name = $document_product_name;
165 | }
166 |
167 | /**
168 | * Get the value of DOCUMENT_PRODUCT_QTD
169 | *
170 | * @return int
171 | */
172 | public function getDocumentProductQtd()
173 | {
174 | return $this->document_product_qtd;
175 | }
176 |
177 | /**
178 | * Quantidade de itens
179 | *
180 | * @param int $document_product_qtd
181 | */
182 | public function setDocumentProductQtd(int $document_product_qtd)
183 | {
184 | $this->document_product_qtd = $document_product_qtd;
185 | }
186 |
187 | /**
188 | * Get the value of DOCUMENT_PRODUCT_UNITARY_VALUE
189 | *
190 | * @return float
191 | */
192 | public function getDocumentProductUnitaryValue()
193 | {
194 | return $this->document_product_unitary_value;
195 | }
196 |
197 | /**
198 | * Valor unitário do item
199 | *
200 | * @param float $document_product_unitary_value
201 | */
202 | public function setDocumentProductUnitaryValue(float $document_product_unitary_value)
203 | {
204 | $this->document_product_unitary_value = $document_product_unitary_value;
205 | }
206 |
207 | /**
208 | * Get the value of DOCUMENT_PRODUCT_NCM
209 | *
210 | * @return int
211 | */
212 | public function getDocumentProductNcm()
213 | {
214 | return $this->document_product_ncm;
215 | }
216 |
217 | /**
218 | * Set the value of DOCUMENT_PRODUCT_NCM
219 | *
220 | * @param int $document_product_ncm
221 | */
222 | public function setDocumentProductNcm(int $document_product_ncm)
223 | {
224 | $this->document_product_ncm = $document_product_ncm;
225 | }
226 |
227 | /**
228 | * Get the value of DOCUMENT_PRODUCT_CEST
229 | *
230 | * @return int
231 | */
232 | public function getDocumentProductCest()
233 | {
234 | return $this->document_product_cest;
235 | }
236 |
237 | /**
238 | * Set the value of DOCUMENT_PRODUCT_CEST
239 | *
240 | * @param int $document_product_cest
241 | */
242 | public function setDocumentProductCest(int $document_product_cest)
243 | {
244 | $this->document_product_cest = $document_product_cest;
245 | }
246 |
247 | /**
248 | * Get the value of DOCUMENT_PRODUCT_CFOP
249 | *
250 | * @return int
251 | */
252 | public function getDocumentProductCfop()
253 | {
254 | return $this->document_product_cfop;
255 | }
256 |
257 | /**
258 | * Set the value of DOCUMENT_PRODUCT_CFOP
259 | *
260 | * @param int $document_product_cfop
261 | */
262 | public function setDocumentProductCfop(int $document_product_cfop)
263 | {
264 | $this->document_product_cfop = $document_product_cfop;
265 | }
266 |
267 | /**
268 | * Get the value of DOCUMENT_PRODUCT_DISCOUNT
269 | *
270 | * @return float
271 | */
272 | public function getDocumentProductDiscount()
273 | {
274 | return $this->document_product_discount;
275 | }
276 |
277 | /**
278 | * Set the value of DOCUMENT_PRODUCT_DISCOUNT
279 | *
280 | * @param float $document_product_discount
281 | */
282 | public function setDocumentProductDiscount(float $document_product_discount)
283 | {
284 | $this->document_product_discount = $document_product_discount;
285 | }
286 |
287 | /**
288 | * Get the value of DOCUMENT_PRODUCT_ICMS_CST
289 | *
290 | * @return int
291 | */
292 | public function getDocumentProductIcmsCst()
293 | {
294 | return $this->document_product_icms_cst;
295 | }
296 |
297 | /**
298 | * Set the value of DOCUMENT_PRODUCT_ICMS_CST
299 | *
300 | * @param int $document_product_icms_cst
301 | */
302 | public function setDocumentProductIcmsCst(int $document_product_icms_cst)
303 | {
304 | $this->document_product_icms_cst = $document_product_icms_cst;
305 | }
306 |
307 | /**
308 | * Get the value of DOCUMENT_PRODUCT_ICMS_ALIQUOTA
309 | *
310 | * @return float
311 | */
312 | public function getDocumentProductIcmsAliquota()
313 | {
314 | return $this->document_product_icms_aliquota;
315 | }
316 |
317 | /**
318 | * Set the value of DOCUMENT_PRODUCT_ICMS_ALIQUOTA
319 | *
320 | * @param float $document_product_icms_aliquota
321 | */
322 | public function setDocumentProductIcmsAliquota(float $document_product_icms_aliquota)
323 | {
324 | $this->document_product_icms_aliquota = $document_product_icms_aliquota;
325 | }
326 |
327 | /**
328 | * Get the value of DOCUMENT_PRODUCT_IPI_CST
329 | *
330 | * @return int
331 | */
332 | public function getDocumentProductIpiCst()
333 | {
334 | return $this->document_product_ipi_cst;
335 | }
336 |
337 | /**
338 | * Set the value of DOCUMENT_PRODUCT_IPI_CST
339 | *
340 | * @param int $document_product_ipi_cst
341 | */
342 | public function setDocumentProductIpiCst(int $document_product_ipi_cst)
343 | {
344 | $this->document_product_ipi_cst = $document_product_ipi_cst;
345 | }
346 |
347 | /**
348 | * Get the value of DOCUMENT_PRODUCT_IPI_ALIQUOTA
349 | *
350 | * @return float
351 | */
352 | public function getDocumentProductIpiAliquota()
353 | {
354 | return $this->document_product_ipi_aliquota;
355 | }
356 |
357 | /**
358 | * Set the value of DOCUMENT_PRODUCT_IPI_ALIQUOTA
359 | *
360 | * @param float $document_product_ipi_aliquota
361 | */
362 | public function setDocumentProductIpiAliquota(float $document_product_ipi_aliquota)
363 | {
364 | $this->document_product_ipi_aliquota = $document_product_ipi_aliquota;
365 | }
366 |
367 | /**
368 | * Get the value of DOCUMENT_PRODUCT_PIS_ALIQUOTA
369 | *
370 | * @return float
371 | */
372 | public function getDocumentProductPisAliquota()
373 | {
374 | return $this->document_product_pis_aliquota;
375 | }
376 |
377 | /**
378 | * Set the value of DOCUMENT_PRODUCT_PIS_ALIQUOTA
379 | *
380 | * @param float $document_product_pis_aliquota
381 | */
382 | public function setDocumentProductPisAliquota(float $document_product_pis_aliquota)
383 | {
384 | $this->document_product_pis_aliquota = $document_product_pis_aliquota;
385 | }
386 |
387 | /**
388 | * Get the value of DOCUMENT_PRODUCT_COFINS_CST
389 | *
390 | * @return float
391 | */
392 | public function getDocumentProductCofinsCst()
393 | {
394 | return $this->document_product_cofins_cst;
395 | }
396 |
397 | /**
398 | * Set the value of DOCUMENT_PRODUCT_COFINS_CST
399 | *
400 | * @param float $document_product_cofins_cst
401 | */
402 | public function setDocumentProductCofinsCst(float $document_product_cofins_cst)
403 | {
404 | $this->document_product_cofins_cst = $document_product_cofins_cst;
405 | }
406 |
407 | /**
408 | * Get the value of DOCUMENT_PRODUCT_COFINS_ALIQUOTA
409 | *
410 | * @return float
411 | */
412 | public function getDocumentProductCofinsAliquota()
413 | {
414 | return $this->document_product_cofins_aliquota;
415 | }
416 |
417 | /**
418 | * Set the value of DOCUMENT_PRODUCT_COFINS_ALIQUOTA
419 | *
420 | * @param float $document_product_cofins_aliquota
421 | */
422 | public function setDocumentProductCofinsAliquota(float $document_product_cofins_aliquota)
423 | {
424 | $this->document_product_cofins_aliquota = $document_product_cofins_aliquota;
425 | }
426 | }
427 |
--------------------------------------------------------------------------------
/src/Multiverse/Notazz/NFe/Products.php:
--------------------------------------------------------------------------------
1 | document_product[] = $item->toArray();
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/Multiverse/Notazz/NFe/Shipping.php:
--------------------------------------------------------------------------------
1 | document_frete[] = $items;
38 | }
39 |
40 | /**
41 | * Get the value of document_frete_mod
42 | *
43 | * @return int
44 | */
45 | public function getDocumentFreteMod(): int
46 | {
47 | return $this->document_frete_mod;
48 | }
49 |
50 | /**
51 | * 0 = Por conta do emitente
52 | * 1 = Por conta do destinatário / remetente
53 | * 2 = Por conta de terceiros
54 | * 9 = Sem frete
55 | *
56 | * @param int $document_frete_mod
57 | */
58 | public function setDocumentFreteMod(int $document_frete_mod)
59 | {
60 | $this->document_frete_mod = $document_frete_mod;
61 | }
62 |
63 | /**
64 | * Get the value of document_frete_value
65 | *
66 | * @return float
67 | */
68 | public function getDocumentFreteValue(): float
69 | {
70 | return $this->document_frete_value;
71 | }
72 |
73 | /**
74 | * Set the value of document_frete_value
75 | *
76 | * @param float $document_frete_value
77 | */
78 | public function setDocumentFreteValue(float $document_frete_value)
79 | {
80 | $this->document_frete_value = $document_frete_value;
81 | }
82 |
83 | /**
84 | * Get the value of document_frete_transportadora
85 | *
86 | * @return array
87 | */
88 | public function getDocumentFreteTransportadora(): array
89 | {
90 | return $this->document_frete_transportadora;
91 | }
92 |
93 | /**
94 | * Set the value of document_frete_transportadora
95 | *
96 | * @param array $document_frete_transportadora
97 | */
98 | public function setDocumentFreteTransportadora(ShippingCarrier $document_frete_transportadora)
99 | {
100 | $this->document_frete_transportadora = $document_frete_transportadora->toArray();
101 | }
102 |
103 | /**
104 | * Get the value of document_frete_veiculo
105 | *
106 | * @return array
107 | */
108 | public function getDocumentFreteVeiculo(): array
109 | {
110 | return $this->document_frete_veiculo;
111 | }
112 |
113 | /**
114 | * Set the value of document_frete_veiculo
115 | *
116 | * @param array $document_frete_veiculo
117 | */
118 | public function setDocumentFreteVeiculo(ShippingVehicles $document_frete_veiculo)
119 | {
120 | $this->document_frete_veiculo = $document_frete_veiculo->toArray();
121 | }
122 |
123 | /**
124 | * Get the value of document_frete_volumes
125 | *
126 | * @return array
127 | */
128 | public function getDocumentFreteVolumes(): array
129 | {
130 | return $this->document_frete_volumes;
131 | }
132 |
133 | /**
134 | * Set the value of document_frete_volumes
135 | *
136 | * @param array $document_frete_volumes
137 | */
138 | public function setDocumentFreteVolumes(ShippingVolumes $document_frete_volumes)
139 | {
140 | $this->document_frete_volumes = $document_frete_volumes->toArray();
141 | }
142 |
143 | public function toArray()
144 | {
145 | $array = [];
146 |
147 | foreach ($this as $key => $value) {
148 | if ($value === null) {
149 | continue;
150 | }
151 | if ($key === 'document_frete') {
152 | continue;
153 | }
154 | $array[strtoupper($key)] = $value;
155 | }
156 |
157 | $this->document_frete['DOCUMENT_FRETE'] = $array;
158 |
159 | return $this->document_frete;
160 | }
161 | }
162 |
--------------------------------------------------------------------------------
/src/Multiverse/Notazz/NFe/ShippingCarrier.php:
--------------------------------------------------------------------------------
1 | document_frete_transportadora_name;
51 | }
52 |
53 | /**
54 | * Nome ou Razão Social da transportadora
55 | *
56 | * @param string $document_frete_transportadora_name
57 | */
58 | public function setDocumentFreteTransportadoraName(string $document_frete_transportadora_name)
59 | {
60 | $this->document_frete_transportadora_name = $document_frete_transportadora_name;
61 | }
62 |
63 | /**
64 | * Get the value of document_frete_transportadora_taxid
65 | *
66 | * @return string
67 | */
68 | public function getDocumentFreteTransportadoraTaxid()
69 | {
70 | return $this->document_frete_transportadora_taxid;
71 | }
72 |
73 | /**
74 | * CPF / CNPJ
75 | *
76 | * @param string $document_frete_transportadora_taxid
77 | */
78 | public function setDocumentFreteTransportadoraTaxid(string $document_frete_transportadora_taxid)
79 | {
80 | $this->document_frete_transportadora_taxid = $document_frete_transportadora_taxid;
81 | }
82 |
83 | /**
84 | * Get the value of document_frete_transportadora_ie
85 | *
86 | * @return int
87 | */
88 | public function getDocumentFreteTransportadoraIe()
89 | {
90 | return $this->document_frete_transportadora_ie;
91 | }
92 |
93 | /**
94 | * Inscrição estadual
95 | *
96 | * @param int $document_frete_transportadora_ie
97 | */
98 | public function setDocumentFreteTransportadoraIe(int $document_frete_transportadora_ie)
99 | {
100 | $this->document_frete_transportadora_ie = $document_frete_transportadora_ie;
101 | }
102 |
103 | /**
104 | * Get the value of document_frete_transportadora_street
105 | *
106 | * @return string
107 | */
108 | public function getDocumentFreteTransportadoraStreet()
109 | {
110 | return $this->document_frete_transportadora_street;
111 | }
112 |
113 | /**
114 | * Logradouro
115 | *
116 | * @param string $document_frete_transportadora_street
117 | */
118 | public function setDocumentFreteTransportadoraStreet(string $document_frete_transportadora_street)
119 | {
120 | $this->document_frete_transportadora_street = $document_frete_transportadora_street;
121 | }
122 |
123 | /**
124 | * Get the value of document_frete_transportadora_number
125 | *
126 | * @return string
127 | */
128 | public function getDocumentFreteTransportadoraNumber()
129 | {
130 | return $this->document_frete_transportadora_number;
131 | }
132 |
133 | /**
134 | * Número
135 | *
136 | * @param string $document_frete_transportadora_number
137 | */
138 | public function setDocumentFreteTransportadoraNumber(string $document_frete_transportadora_number)
139 | {
140 | $this->document_frete_transportadora_number = $document_frete_transportadora_number;
141 | }
142 |
143 | /**
144 | * Get the value of document_frete_transportadora_district
145 | *
146 | * @return string
147 | */
148 | public function getDocumentFreteTransportadoraDistrict()
149 | {
150 | return $this->document_frete_transportadora_district;
151 | }
152 |
153 | /**
154 | * Bairro
155 | *
156 | * @param string $document_frete_transportadora_district
157 | */
158 | public function setDocumentFreteTransportadoraDistrict(string $document_frete_transportadora_district)
159 | {
160 | $this->document_frete_transportadora_district = $document_frete_transportadora_district;
161 | }
162 |
163 | /**
164 | * Get the value of document_frete_transportadora_city
165 | *
166 | * @return string
167 | */
168 | public function getDocumentFreteTransportadoraCity()
169 | {
170 | return $this->document_frete_transportadora_city;
171 | }
172 |
173 | /**
174 | * Cidade
175 | *
176 | * @param string $document_frete_transportadora_city
177 | */
178 | public function setDocumentFreteTransportadoraCity(string $document_frete_transportadora_city)
179 | {
180 | $this->document_frete_transportadora_city = $document_frete_transportadora_city;
181 | }
182 |
183 | /**
184 | * Get the value of document_frete_transportadora_uf
185 | *
186 | * @return string
187 | */
188 | public function getDocumentFreteTransportadoraUf()
189 | {
190 | return $this->document_frete_transportadora_uf;
191 | }
192 |
193 | /**
194 | * UF
195 | *
196 | * @param string $document_frete_transportadora_uf
197 | */
198 | public function setDocumentFreteTransportadoraUf(string $document_frete_transportadora_uf)
199 | {
200 | $this->document_frete_transportadora_uf = $document_frete_transportadora_uf;
201 | }
202 | }
203 |
--------------------------------------------------------------------------------
/src/Multiverse/Notazz/NFe/ShippingVehicles.php:
--------------------------------------------------------------------------------
1 | document_frete_veiculo_placa;
24 | }
25 |
26 | /**
27 | * Placa do veículo
28 | */
29 | public function setDocumentFreteVeiculoPlaca(string $document_frete_veiculo_placa)
30 | {
31 | $this->document_frete_veiculo_placa = $document_frete_veiculo_placa;
32 | }
33 |
34 | /**
35 | * Get the value of document_frete_veiculo_uf
36 | */
37 | public function getDocumentFreteVeiculoUf(): string
38 | {
39 | return $this->document_frete_veiculo_uf;
40 | }
41 |
42 | /**
43 | * Estado do veículo
44 | */
45 | public function setDocumentFreteVeiculoUf(string $document_frete_veiculo_uf)
46 | {
47 | $this->document_frete_veiculo_uf = $document_frete_veiculo_uf;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/Multiverse/Notazz/NFe/ShippingVolumes.php:
--------------------------------------------------------------------------------
1 | document_frete_volumes_qtd;
34 | }
35 |
36 | /**
37 | * Quantidade de volumes
38 | *
39 | * @param int $document_frete_volumes_qtd
40 | */
41 | public function setDocumentFreteVolumesQtd(int $document_frete_volumes_qtd)
42 | {
43 | $this->document_frete_volumes_qtd = $document_frete_volumes_qtd;
44 | }
45 |
46 | /**
47 | * Get the value of document_frete_volumes_species
48 | *
49 | * @return string
50 | */
51 | public function getDocumentFreteVolumesSpecies(): string
52 | {
53 | return $this->document_frete_volumes_species;
54 | }
55 |
56 | /**
57 | * Espécie dos volumes. Ex.: CAIXA, FARDO
58 | *
59 | * @param string $document_frete_volumes_species
60 | */
61 | public function setDocumentFreteVolumesSpecies(string $document_frete_volumes_species)
62 | {
63 | $this->document_frete_volumes_species = $document_frete_volumes_species;
64 | }
65 |
66 | /**
67 | * Get the value of document_frete_volumes_net_weight
68 | *
69 | * @return float
70 | */
71 | public function getDocumentFreteVolumesNetWeight(): float
72 | {
73 | return $this->document_frete_volumes_net_weight;
74 | }
75 |
76 | /**
77 | * Peso líquido em KG
78 | *
79 | * @param float $document_frete_volumes_net_weight
80 | */
81 | public function setDocumentFreteVolumesNetWeight(float $document_frete_volumes_net_weight)
82 | {
83 | $this->document_frete_volumes_net_weight = $document_frete_volumes_net_weight;
84 | }
85 |
86 | /**
87 | * Get the value of document_frete_volumes_gross_weight
88 | *
89 | * @return float
90 | */
91 | public function getDocumentFreteVolumesGrossWeight(): float
92 | {
93 | return $this->document_frete_volumes_gross_weight;
94 | }
95 |
96 | /**
97 | * Peso bruto em KG
98 | *
99 | * @param float $document_frete_volumes_gross_weight
100 | */
101 | public function setDocumentFreteVolumesGrossWeight(float $document_frete_volumes_gross_weight)
102 | {
103 | $this->document_frete_volumes_gross_weight = $document_frete_volumes_gross_weight;
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/src/Multiverse/Notazz/NotaFiscal.php:
--------------------------------------------------------------------------------
1 | api_key = $apiKey;
35 |
36 | $this->method = 'create_nfe_55';
37 |
38 | if ($nfeType instanceof \Multiverse\Notazz\NFSe) {
39 | $this->method = 'create_nfse';
40 | }
41 |
42 | $this->setNota($nfeType);
43 | }
44 |
45 | /**
46 | * @param
47 | */
48 | public function setHandler($handler)
49 | {
50 | $this->handler = $handler;
51 | }
52 |
53 | /**
54 | * @param
55 | */
56 | protected function setNota($nota)
57 | {
58 | $this->nota = $nota->mount();
59 | }
60 |
61 | /**
62 | * @return mixed
63 | */
64 | protected function sendRequest()
65 | {
66 | try {
67 | $response = $this->handler->request('POST', self::API_URL, [
68 | 'form_params' => [
69 | "fields" => $this->prepareRequest()
70 | ],
71 | false
72 | ]);
73 |
74 | $result = json_decode($response->getBody()->getContents());
75 |
76 | if ($result->statusProcessamento === 'erro') {
77 | throw new ErrorStatusProcessamentoException("Error when generating the invoice: $result->motivo", 400);
78 | }
79 |
80 | return $result;
81 | } catch (\Exception $e) {
82 | throw $e;
83 | }
84 | }
85 |
86 | /**
87 | * @return mixed
88 | */
89 | public function create()
90 | {
91 | return $this->sendRequest();
92 | }
93 |
94 | public function prepareRequest()
95 | {
96 | $this->nota['API_KEY'] = $this->api_key;
97 | $this->nota['METHOD'] = $this->method;
98 |
99 | return json_encode($this->nota);
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/src/Multiverse/Notazz/Resource.php:
--------------------------------------------------------------------------------
1 | $value) {
14 | if ($value === null) {
15 | continue;
16 | }
17 | $array[strtoupper($key)] = $value;
18 | }
19 | return $array;
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/tests/FirstTest.php:
--------------------------------------------------------------------------------
1 | expectException(MethodNotFoundException::class);
24 |
25 | $destination
26 | ->name('Leonardo Tumadjian')
27 | ->tax('3333.333.333-33')
28 | ;
29 | }
30 |
31 | public function testDSLDestinationBuilderCouldBeFullFilled()
32 | {
33 | $destination = new DestinationBuilder();
34 |
35 | $destination
36 | ->name('John Doe')
37 | ->taxid('00000000272')
38 | ->taxtype('F')
39 | ->street('NÃO INFORMADO')
40 | ->number('S/N')
41 | ->district('NÃO INFORMADO')
42 | ->city('São Paulo')
43 | ->uf('SP')
44 | ->zipcode('02102000')
45 | ->email('teste@gmail.com')
46 | ->sendEmailList()
47 | ->add('teste1@gmail.com')
48 | ->add('teste2@gmail.com')
49 | ->end()
50 | ->phone('11955555555')
51 | ;
52 |
53 | $generated = $destination->getArray();
54 |
55 | $result = [
56 | 'DESTINATION_NAME' => 'John Doe',
57 | 'DESTINATION_TAXID' => '00000000272',
58 | 'DESTINATION_TAXTYPE' => 'F',
59 | 'DESTINATION_STREET' => 'NÃO INFORMADO',
60 | 'DESTINATION_NUMBER' => 'S/N',
61 | 'DESTINATION_DISTRICT' => 'NÃO INFORMADO',
62 | 'DESTINATION_CITY' => 'São Paulo',
63 | 'DESTINATION_UF' => 'SP',
64 | 'DESTINATION_ZIPCODE' => '02102000',
65 | 'DESTINATION_PHONE' => '11955555555',
66 | 'DESTINATION_EMAIL' => 'teste@gmail.com',
67 | 'DESTINATION_EMAIL_SEND' => [
68 | 'teste1@gmail.com',
69 | 'teste2@gmail.com'
70 | ]
71 | ];
72 |
73 | $this->assertEquals($result, $generated);
74 | }
75 |
76 | public function testDSLDestinationBuilderCantAddEmailWrongPlace()
77 | {
78 | $destination = new DestinationBuilder();
79 |
80 | $this->expectException(CantAddEmailException::class);
81 |
82 | $destination
83 | ->name('John Doe')
84 | ->taxid('00000000272')
85 | ->taxtype('F')
86 | ->street('NÃO INFORMADO')
87 | ->number('S/N')
88 | ->district('NÃO INFORMADO')
89 | ->city('São Paulo')
90 | ->uf('SP')
91 | ->zipcode('02102000')
92 | ->email('teste@gmail.com')
93 | ->add('teste1@gmail.com')
94 | ->sendEmailList()
95 | ->add('teste2@gmail.com')
96 | ->end()
97 | ->phone('11955555555')
98 | ;
99 | }
100 |
101 | public function testDSLDocumentBuilderIsNFSE()
102 | {
103 | $document = new DocumentBuilder();
104 |
105 | $document
106 | ->nfse()
107 | ->basevalue(1.00)
108 | ->description('Descrição teste')
109 | ->issue_date('2019-07-05 18:11:30')
110 | ;
111 |
112 | $nf = $document->getInstance();
113 |
114 | $this->assertInstanceOf('Multiverse\Notazz\NFSe\Document', $nf);
115 | }
116 |
117 | public function testDSLDocumentBuilderIsNFE()
118 | {
119 | $document = new DocumentBuilder();
120 |
121 | $document
122 | ->nfe()
123 | ->basevalue(1.00)
124 | ->description('Descrição teste')
125 | ->issue_date('2019-07-05 18:11:30')
126 | ;
127 |
128 | $nf = $document->getInstance();
129 |
130 | $this->assertInstanceOf('Multiverse\Notazz\NFe\Document', $nf);
131 | }
132 |
133 | public function testDSLDocumentClassCouldBeFullFilledNFSE()
134 | {
135 | $document = (new DocumentBuilder())
136 | ->nfse()
137 | ->basevalue(1.00)
138 | ->description('Descrição teste')
139 | ->issue_date('2019-07-05 18:11:30')
140 | ->competence('2019-07-05 18:11:30')
141 | ;
142 |
143 | $generated = $document->getArray();
144 |
145 | $result = [
146 | 'DOCUMENT_BASEVALUE' => 1.00,
147 | 'DOCUMENT_DESCRIPTION' => 'Descrição teste',
148 | 'DOCUMENT_ISSUE_DATE' => '2019-07-05 18:11:30',
149 | 'DOCUMENT_COMPETENCE' => '2019-07-05 18:11:30',
150 | ];
151 |
152 | $this->assertEquals($result, $generated);
153 | }
154 |
155 | public function testDSLDocumentClassCouldBeFullFilledNFE()
156 | {
157 | $document = (new DocumentBuilder())
158 | ->nfe()
159 | ->basevalue(1.00)
160 | ->description('Descrição teste')
161 | ->issue_date('2019-07-05 18:11:30')
162 | ;
163 |
164 | $generated = $document->getArray();
165 |
166 | $result = [
167 | 'DOCUMENT_BASEVALUE' => 1.00,
168 | 'DOCUMENT_DESCRIPTION' => 'Descrição teste',
169 | 'DOCUMENT_ISSUE_DATE' => '2019-07-05 18:11:30',
170 | ];
171 |
172 | $this->assertEquals($result, $generated);
173 | }
174 |
175 | public function testDSLDocumentClassShouldBeNFE()
176 | {
177 | $document = (new DocumentBuilder())
178 | ->nfe()
179 | ->basevalue(1.00)
180 | ->description('Descrição teste')
181 | ->issue_date('2019-07-05 18:11:30')
182 | ;
183 |
184 | $this->assertEquals($document::NFE, $document->getDocumentType());
185 | }
186 |
187 | public function testDSLDocumentClassCouldBeNFSE()
188 | {
189 | $document = (new DocumentBuilder())
190 | ->nfse()
191 | ->basevalue(1.00)
192 | ->description('Descrição teste')
193 | ->issue_date('2019-07-05 18:11:30')
194 | ->competence('2019-07-05 18:11:30')
195 | ;
196 |
197 | $generated = $document->getArray();
198 |
199 | $this->assertEquals($document::NFSE, $document->getDocumentType());
200 | }
201 |
202 | public function testDSLDocumentBuilderProduct()
203 | {
204 | $products = (new ProductsBuilder())
205 | ->add()
206 | ->cod(123)
207 | ->name('Escova de dentes Cepacol')
208 | ->qtd(2)
209 | ->unitary_value(15.20)
210 | ->ncm(123)
211 | ->save()
212 | ->add()
213 | ->cod(123)
214 | ->name('Pano de prato para cozinha')
215 | ->qtd(1)
216 | ->unitary_value(55.10)
217 | ->ncm(123)
218 | ->save()
219 | ;
220 |
221 | $result = [
222 | 'DOCUMENT_PRODUCT' => [
223 | [
224 | 'DOCUMENT_PRODUCT_COD' => 123,
225 | 'DOCUMENT_PRODUCT_NAME' => 'Escova de dentes Cepacol',
226 | 'DOCUMENT_PRODUCT_QTD' => 2,
227 | 'DOCUMENT_PRODUCT_UNITARY_VALUE' => 15.20,
228 | 'DOCUMENT_PRODUCT_NCM' => 123
229 | ],
230 | [
231 | 'DOCUMENT_PRODUCT_COD' => 123,
232 | 'DOCUMENT_PRODUCT_NAME' => 'Pano de prato para cozinha',
233 | 'DOCUMENT_PRODUCT_QTD' => 1,
234 | 'DOCUMENT_PRODUCT_UNITARY_VALUE' => 55.10,
235 | 'DOCUMENT_PRODUCT_NCM' => 123
236 | ]
237 | ]
238 | ];
239 |
240 | $this->assertEquals($result, $products->getArray());
241 | }
242 |
243 | public function testDSLAliquotasClassCouldBeFullFilledNFSE()
244 | {
245 | $aliquotas = new AliquotasBuilder();
246 |
247 | $aliquotas
248 | ->cofins(1.0)
249 | ->csll(0.10)
250 | ->inss(2.01)
251 | ->ir(1.05)
252 | ->pis(0.5)
253 | ->iss(0.08)
254 | ;
255 |
256 | $result = [
257 | 'COFINS' => 1,
258 | 'CSLL' => 0.1,
259 | 'INSS' => 2.01,
260 | 'IR' => 1.05,
261 | 'PIS' => 0.5,
262 | 'ISS' => 0.08
263 | ];
264 |
265 | $this->assertEquals($result, $aliquotas->getArray());
266 | }
267 |
268 | public function testDSLServiceClassCouldBeFullFilledNFSE()
269 | {
270 | $service = new ServiceBuilder();
271 |
272 | $service
273 | ->description('Teste')
274 | ->listLc116(123)
275 | ->withheldIss(123)
276 | ->cityCode(123)
277 | ->aliquotas()
278 | ->cofins(1.0)
279 | ->csll(0.10)
280 | ->inss(2.01)
281 | ->ir(1.05)
282 | ->pis(0.5)
283 | ->iss(0.08)
284 | ->save()
285 | ;
286 |
287 | $result = [
288 | 'CITY_SERVICE_DESCRIPTION' => 'Teste',
289 | 'SERVICE_LIST_LC116' => 123,
290 | 'WITHHELD_ISS' => 123,
291 | 'CITY_SERVICE_CODE' => 123,
292 | 'ALIQUOTAS' => array(
293 | 'COFINS' => 1.0,
294 | 'CSLL' => 0.10,
295 | 'INSS' => 2.01,
296 | 'IR' => 1.05,
297 | 'PIS' => 0.5,
298 | 'ISS' => 0.08,
299 | )
300 | ];
301 |
302 | $this->assertEquals($result, $service->getArray());
303 | }
304 |
305 | public function testDSLShippingVehiclesClassCouldBeFullFilledNFSE()
306 | {
307 | $shippingVehicles = new ShippingVehiclesBuilder();
308 |
309 | $result = [
310 | "DOCUMENT_FRETE_VEICULO_PLACA" => "ZZZ1100",
311 | "DOCUMENT_FRETE_VEICULO_UF" => "MG"
312 | ];
313 |
314 | $shippingVehicles
315 | ->placa('ZZZ1100')
316 | ->uf('MG')
317 | ;
318 |
319 | $this->assertEquals($result, $shippingVehicles->getArray());
320 | }
321 |
322 | public function testDSLShippingVolumesClassCouldBeFullFilledNFSE()
323 | {
324 | $shippingVolumes = new ShippingVolumesBuilder();
325 |
326 | $result = [
327 | "DOCUMENT_FRETE_VOLUMES_QTD" => "1",
328 | "DOCUMENT_FRETE_VOLUMES_SPECIES" => "CAIXA",
329 | "DOCUMENT_FRETE_VOLUMES_NET_WEIGHT" => "10.500",
330 | "DOCUMENT_FRETE_VOLUMES_GROSS_WEIGHT" => "12.000"
331 | ];
332 |
333 | $shippingVolumes
334 | ->qtd(1)
335 | ->species('CAIXA')
336 | ->netWeight(10.500)
337 | ->grossWeight(12.000)
338 | ;
339 |
340 | $this->assertEquals($result, $shippingVolumes->getArray());
341 | }
342 |
343 | public function testDSLShippingCarrierClassCouldBeFullFilledNFSE()
344 | {
345 | $shippingCarrier = new ShippingCarrierBuilder();
346 |
347 | $result = [
348 | "DOCUMENT_FRETE_TRANSPORTADORA_NAME" => "Empresa Brasileira de Correios e Telégrafos",
349 | "DOCUMENT_FRETE_TRANSPORTADORA_TAXID" => "34028316002742",
350 | "DOCUMENT_FRETE_TRANSPORTADORA_IE" => "12345678",
351 | "DOCUMENT_FRETE_TRANSPORTADORA_STREET" => "Rua de teste",
352 | "DOCUMENT_FRETE_TRANSPORTADORA_NUMBER" => "123",
353 | "DOCUMENT_FRETE_TRANSPORTADORA_DISTRICT" => "Centro",
354 | "DOCUMENT_FRETE_TRANSPORTADORA_CITY" => "Belo Horizonte",
355 | "DOCUMENT_FRETE_TRANSPORTADORA_UF" => "MG"
356 | ];
357 |
358 | $shippingCarrier
359 | ->name('Empresa Brasileira de Correios e Telégrafos')
360 | ->taxid('34028316002742')
361 | ->ie(12345678)
362 | ->street('Rua de teste')
363 | ->number(123)
364 | ->district('Centro')
365 | ->city('Belo Horizonte')
366 | ->uf('MG')
367 | ;
368 |
369 | $this->assertEquals($result, $shippingCarrier->getArray());
370 | }
371 |
372 | public function testDSLShippingClassCouldBeFullFilledNFSE()
373 | {
374 | $shipping = new ShippingBuilder();
375 |
376 | $result = [
377 | "DOCUMENT_FRETE" => [
378 | "DOCUMENT_FRETE_MOD" => "0",
379 | "DOCUMENT_FRETE_VALUE" => "100.00",
380 | "DOCUMENT_FRETE_TRANSPORTADORA" => [
381 | "DOCUMENT_FRETE_TRANSPORTADORA_NAME" => "Empresa Brasileira de Correios e Telégrafos",
382 | "DOCUMENT_FRETE_TRANSPORTADORA_TAXID" => "34028316002742",
383 | "DOCUMENT_FRETE_TRANSPORTADORA_IE" => "12345678",
384 | "DOCUMENT_FRETE_TRANSPORTADORA_STREET" => "Rua de teste",
385 | "DOCUMENT_FRETE_TRANSPORTADORA_NUMBER" => "123",
386 | "DOCUMENT_FRETE_TRANSPORTADORA_DISTRICT" => "Centro",
387 | "DOCUMENT_FRETE_TRANSPORTADORA_CITY" => "Belo Horizonte",
388 | "DOCUMENT_FRETE_TRANSPORTADORA_UF" => "MG"
389 | ],
390 | "DOCUMENT_FRETE_VEICULO" => [
391 | "DOCUMENT_FRETE_VEICULO_PLACA" => "ZZZ1100",
392 | "DOCUMENT_FRETE_VEICULO_UF" => "MG"
393 | ],
394 | "DOCUMENT_FRETE_VOLUMES" => [
395 | "DOCUMENT_FRETE_VOLUMES_QTD" => "1",
396 | "DOCUMENT_FRETE_VOLUMES_SPECIES" => "CAIXA",
397 | "DOCUMENT_FRETE_VOLUMES_NET_WEIGHT" => "10.500",
398 | "DOCUMENT_FRETE_VOLUMES_GROSS_WEIGHT" => "12.000"
399 | ]
400 | ]
401 | ];
402 |
403 | $shipping
404 | ->value(100.00)
405 | ->mode(0)
406 | ->vehicles()
407 | ->placa('ZZZ1100')
408 | ->uf('MG')
409 | ->volumes()
410 | ->qtd(1)
411 | ->species('CAIXA')
412 | ->netWeight(10.500)
413 | ->grossWeight(12.000)
414 | ->carrier()
415 | ->name('Empresa Brasileira de Correios e Telégrafos')
416 | ->taxid('34028316002742')
417 | ->ie(12345678)
418 | ->street('Rua de teste')
419 | ->number(123)
420 | ->district('Centro')
421 | ->city('Belo Horizonte')
422 | ->uf('MG')
423 | ->save();
424 |
425 | $this->assertEquals($result, $shipping->getArray());
426 | }
427 | }
428 |
--------------------------------------------------------------------------------
/tests/NotafiscalNFSeSendTest.php:
--------------------------------------------------------------------------------
1 | apiKey = '123';
19 |
20 | $this->notafiscal = new NotaFiscalBuilder();
21 | }
22 |
23 | public function testNotaFiscalBuilderIsNfse()
24 | {
25 | $client = $this->createMock(Client::class);
26 |
27 | $response = $this->createMock(Response::class);
28 |
29 | $stream = $this->createMock(Stream::class);
30 |
31 | $client->method('request')
32 | ->willReturn($response);
33 |
34 | $response->method('getBody')
35 | ->willReturn($stream);
36 |
37 | $stream->method('getContents')
38 | ->willReturn('{"statusProcessamento":"sucesso","codigoProcessamento":"000","id":"123"}');
39 |
40 | $result =
41 | $this->notafiscal
42 | ->setRequestHandler($client)
43 | ->key('123')
44 | ->destination()
45 | ->name('Leonardo Tumadjian')
46 | ->taxid('00000000272')
47 | ->taxtype('F')
48 | ->street('NÃO INFORMADO')
49 | ->number('S/N')
50 | ->district('NÃO INFORMADO')
51 | ->city('São Paulo')
52 | ->uf('SP')
53 | ->zipcode('02102000')
54 | ->email('teste@gmail.com')
55 | ->sendEmailList()
56 | ->add('teste1@gmail.com')
57 | ->add('teste2@gmail.com')
58 | ->end()
59 | ->phone(11955555555)
60 | ->document()
61 | ->nfse()
62 | ->basevalue(0.10)
63 | ->description('Descrição teste')
64 | ->issue_date('2019-07-05 18:11:30')
65 | ->service()
66 | ->description('Teste')
67 | ->listLc116(123)
68 | ->withheldIss(123)
69 | ->cityCode(123)
70 | ->aliquotas()
71 | ->cofins(1.0)
72 | ->csll(0.10)
73 | ->inss(2.01)
74 | ->ir(1.05)
75 | ->pis(0.5)
76 | ->iss(0.08)
77 | ->save()
78 | ->make()
79 | ;
80 |
81 | $expectedResult = new \stdClass();
82 |
83 | $expectedResult->statusProcessamento = 'sucesso';
84 | $expectedResult->codigoProcessamento = '000';
85 | $expectedResult->id = '123';
86 |
87 | $this->assertEquals($expectedResult, $result);
88 | }
89 |
90 | public function testNotaFiscalBuilderIsNfseRemote()
91 | {
92 | $this->expectException(ErrorStatusProcessamentoException::class);
93 |
94 | $client = $this->createMock(Client::class);
95 |
96 | $response = $this->createMock(Response::class);
97 |
98 | $stream = $this->createMock(Stream::class);
99 |
100 | $client->method('request')
101 | ->willReturn($response);
102 |
103 | $response->method('getBody')
104 | ->willReturn($stream);
105 |
106 | $stream->method('getContents')
107 | ->willReturn('{"statusProcessamento":"erro","motivo": "Erro ao processar"}');
108 |
109 | $this->notafiscal
110 | ->setRequestHandler($client)
111 | ->key('123')
112 | ->destination()
113 | ->name('John Doe')
114 | ->taxid('00000000272')
115 | ->taxtype('F')
116 | ->street('NÃO INFORMADO')
117 | ->number('S/N')
118 | ->district('NÃO INFORMADO')
119 | ->city('São Paulo')
120 | ->uf('SP')
121 | ->zipcode('02102000')
122 | ->email('teste@gmail.com')
123 | ->sendEmailList()
124 | ->add('teste1@gmail.com')
125 | ->add('teste2@gmail.com')
126 | ->end()
127 | ->phone(11955555555)
128 | ->document()
129 | ->nfse()
130 | ->basevalue(1.10)
131 | ->description('Descrição teste')
132 | ->issue_date('2019-07-12 12:14:45')
133 | ->service()
134 | ->description('Teste')
135 | ->listLc116(123)
136 | ->withheldIss(123)
137 | ->cityCode(123)
138 | ->aliquotas()
139 | ->cofins(1.0)
140 | ->csll(0.10)
141 | ->inss(2.01)
142 | ->ir(1.05)
143 | ->pis(0.5)
144 | ->iss(0.08)
145 | ->save()
146 | ->make();
147 | }
148 | }
149 |
--------------------------------------------------------------------------------
/tests/NotafiscalNFSeTest.php:
--------------------------------------------------------------------------------
1 | notafiscal = new NotaFiscalBuilder($client);
15 | }
16 |
17 | public function testNotaFiscalBuilderIsNFSE()
18 | {
19 | $this->notafiscal
20 | ->key('123')
21 | ->destination()
22 | ->name('John Doe')
23 | ->taxid('00000000272')
24 | ->taxtype('F')
25 | ->street('NÃO INFORMADO')
26 | ->number('S/N')
27 | ->district('NÃO INFORMADO')
28 | ->city('São Paulo')
29 | ->uf('SP')
30 | ->zipcode('02102000')
31 | ->email('teste@gmail.com')
32 | ->sendEmailList()
33 | ->add('teste1@gmail.com')
34 | ->add('teste2@gmail.com')
35 | ->end()
36 | ->phone(11955555555)
37 | ->document()
38 | ->nfse()
39 | ->basevalue(70.30)
40 | ->description('Descrição teste')
41 | ->issue_date('2019-07-05 18:11:30')
42 | ->service()
43 | ->description('Teste')
44 | ->listLc116(123)
45 | ->withheldIss(123)
46 | ->cityCode(123)
47 | ->aliquotas()
48 | ->cofins(1.0)
49 | ->csll(0.10)
50 | ->inss(2.01)
51 | ->ir(1.05)
52 | ->pis(0.5)
53 | ->iss(0.08)
54 | ->save()
55 | ;
56 |
57 | $this->assertFalse($this->notafiscal->isNFE());
58 | }
59 |
60 | public function testNotafiscalBuilderJsonValidated()
61 | {
62 | $this->notafiscal
63 | ->key('123')
64 | ->destination()
65 | ->name('John Doe')
66 | ->taxid('00000000272')
67 | ->taxtype('F')
68 | ->street('NÃO INFORMADO')
69 | ->number('S/N')
70 | ->district('NÃO INFORMADO')
71 | ->city('São Paulo')
72 | ->uf('SP')
73 | ->zipcode('02102000')
74 | ->email('teste@gmail.com')
75 | ->sendEmailList()
76 | ->add('teste1@gmail.com')
77 | ->add('teste2@gmail.com')
78 | ->end()
79 | ->phone(11955555555)
80 | ->document()
81 | ->nfse()
82 | ->basevalue(70.30)
83 | ->description('Descrição teste')
84 | ->issue_date('2019-07-05 18:11:30')
85 | ->competence('2019-07-12 11:52:30')
86 | ->service()
87 | ->description('Teste')
88 | ->listLc116(123)
89 | ->withheldIss(123)
90 | ->cityCode(123)
91 | ->aliquotas()
92 | ->cofins(1.0)
93 | ->csll(0.10)
94 | ->inss(2.01)
95 | ->ir(1.05)
96 | ->pis(0.5)
97 | ->iss(0.08)
98 | ->save()
99 | ;
100 |
101 | $result = <<assertJsonStringEqualsJsonString(
139 | $this->notafiscal->getJson(),
140 | $result
141 | );
142 | }
143 | }
144 |
--------------------------------------------------------------------------------
/tests/NotafiscalNFeSendTest.php:
--------------------------------------------------------------------------------
1 | apiKey = '123';
18 |
19 | $this->notafiscal = new NotaFiscalBuilder();
20 | }
21 |
22 | public function testNotaFiscalBuilderIsNfe()
23 | {
24 | $client = $this->createMock(Client::class);
25 |
26 | $response = $this->createMock(Response::class);
27 |
28 | $stream = $this->createMock(Stream::class);
29 |
30 | $client->method('request')
31 | ->willReturn($response);
32 |
33 | $response->method('getBody')
34 | ->willReturn($stream);
35 |
36 | $stream->method('getContents')
37 | ->willReturn('{"statusProcessamento":"sucesso","codigoProcessamento":"000","id":"123"}');
38 |
39 | $result =
40 | $this->notafiscal
41 | ->setRequestHandler($client)
42 | ->key('123')
43 | ->destination()
44 | ->name('John Doe')
45 | ->taxid('00000000272')
46 | ->taxtype('F')
47 | ->street('NÃO INFORMADO')
48 | ->number('S/N')
49 | ->district('NÃO INFORMADO')
50 | ->city('São Paulo')
51 | ->uf('SP')
52 | ->zipcode('02102000')
53 | ->email('teste@gmail.com')
54 | ->sendEmailList()
55 | ->add('teste1@gmail.com')
56 | ->add('teste2@gmail.com')
57 | ->end()
58 | ->phone(11955555555)
59 | ->document()
60 | ->nfe()
61 | ->basevalue(70.30)
62 | ->description('Descrição teste')
63 | ->issue_date('2019-07-05 18:11:30')
64 | ->products()
65 | ->add()
66 | ->cod(123)
67 | ->name('Escova de dente Cepacol')
68 | ->qtd(2)
69 | ->unitary_value(15.20)
70 | ->save()
71 | ->add()
72 | ->cod(123)
73 | ->name('Pano de prato para cozinha')
74 | ->qtd(1)
75 | ->unitary_value(55.10)
76 | ->save()
77 | ->shipping()
78 | ->value(100.00)
79 | ->mode(0)
80 | ->vehicles()
81 | ->placa('ZZZ1100')
82 | ->uf('MG')
83 | ->volumes()
84 | ->qtd(1)
85 | ->species('CAIXA')
86 | ->netWeight(10.500)
87 | ->grossWeight(12.000)
88 | ->carrier()
89 | ->name('Empresa Brasileira de Correios e Telégrafos')
90 | ->taxid('34028316002742')
91 | ->ie(12345678)
92 | ->street('Rua de teste')
93 | ->number(123)
94 | ->district('Centro')
95 | ->city('Belo Horizonte')
96 | ->uf('MG')
97 | ->save()
98 | ->make()
99 | ;
100 |
101 | $expectedResult = new \stdClass();
102 |
103 | $expectedResult->statusProcessamento = 'sucesso';
104 | $expectedResult->codigoProcessamento = '000';
105 | $expectedResult->id = '123';
106 |
107 | $this->assertEquals($expectedResult, $result);
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/tests/NotafiscalNFeTest.php:
--------------------------------------------------------------------------------
1 | notafiscal = new NotaFiscalBuilder($client);
18 | }
19 |
20 | public function testNotaFiscalBuilderIsNFE()
21 | {
22 | $client = $this->createMock(Client::class);
23 |
24 | $response = $this->createMock(Response::class);
25 |
26 | $stream = $this->createMock(Stream::class);
27 |
28 | $client->method('request')
29 | ->willReturn($response);
30 |
31 | $response->method('getBody')
32 | ->willReturn($stream);
33 |
34 | $stream->method('getContents')
35 | ->willReturn('{"statusProcessamento":"sucesso","codigoProcessamento":"000","id":"123"}');
36 |
37 | $this->notafiscal
38 | ->setRequestHandler($client)
39 | ->key('123')
40 | ->destination()
41 | ->name('John Doe')
42 | ->taxid('00000000272')
43 | ->taxtype('F')
44 | ->street('NÃO INFORMADO')
45 | ->number('S/N')
46 | ->district('NÃO INFORMADO')
47 | ->city('São Paulo')
48 | ->uf('SP')
49 | ->zipcode('02102000')
50 | ->email('teste@gmail.com')
51 | ->sendEmailList()
52 | ->add('teste1@gmail.com')
53 | ->add('teste2@gmail.com')
54 | ->end()
55 | ->phone(11955555555)
56 | ->document()
57 | ->nfe()
58 | ->basevalue(70.30)
59 | ->description('Descrição teste')
60 | ->issue_date('2019-07-05 18:11:30')
61 | ->products()
62 | ->add()
63 | ->cod(123)
64 | ->name('Escova de dentes Cepacol')
65 | ->qtd(2)
66 | ->unitary_value(15.20)
67 | ->save()
68 | ->add()
69 | ->cod(123)
70 | ->name('Pano de prato para cozinha')
71 | ->qtd(1)
72 | ->unitary_value(55.10)
73 | ->save()
74 | ;
75 |
76 | $this->assertTrue($this->notafiscal->isNFE());
77 | }
78 |
79 | public function testNotafiscalBuilderJsonValidated()
80 | {
81 | $client = $this->createMock(Client::class);
82 |
83 | $response = $this->createMock(Response::class);
84 |
85 | $stream = $this->createMock(Stream::class);
86 |
87 | $client->method('request')
88 | ->willReturn($response);
89 |
90 | $response->method('getBody')
91 | ->willReturn($stream);
92 |
93 | $stream->method('getContents')
94 | ->willReturn('{"statusProcessamento":"sucesso","codigoProcessamento":"000","id":"123"}');
95 |
96 | $this->notafiscal
97 | ->setRequestHandler($client)
98 | ->key('123')
99 | ->destination()
100 | ->name('John Doe')
101 | ->taxid('00000000272')
102 | ->taxtype('F')
103 | ->street('NÃO INFORMADO')
104 | ->number('S/N')
105 | ->district('NÃO INFORMADO')
106 | ->city('São Paulo')
107 | ->uf('SP')
108 | ->zipcode('02102000')
109 | ->email('teste@gmail.com')
110 | ->sendEmailList()
111 | ->add('teste1@gmail.com')
112 | ->add('teste2@gmail.com')
113 | ->end()
114 | ->phone(11955555555)
115 | ->document()
116 | ->nfe()
117 | ->basevalue(70.30)
118 | ->description('Descrição teste')
119 | ->issue_date('2019-07-05 18:11:30')
120 | ->products()
121 | ->add()
122 | ->cod(123)
123 | ->name('Escova de dente Cepacol')
124 | ->qtd(2)
125 | ->unitary_value(15.20)
126 | ->save()
127 | ->add()
128 | ->cod(123)
129 | ->name('Pano de prato para cozinha')
130 | ->qtd(1)
131 | ->unitary_value(55.10)
132 | ->save()
133 | ->shipping()
134 | ->value(100.00)
135 | ->mode(0)
136 | ->vehicles()
137 | ->placa('ZZZ1100')
138 | ->uf('MG')
139 | ->volumes()
140 | ->qtd(1)
141 | ->species('CAIXA')
142 | ->netWeight(10.500)
143 | ->grossWeight(12.000)
144 | ->carrier()
145 | ->name('Empresa Brasileira de Correios e Telégrafos')
146 | ->taxid('34028316002742')
147 | ->ie(12345678)
148 | ->street('Rua de teste')
149 | ->number(123)
150 | ->district('Centro')
151 | ->city('Belo Horizonte')
152 | ->uf('MG')
153 | ->save()
154 | ->make()
155 | ;
156 |
157 | $result = <<assertJsonStringEqualsJsonString(
220 | $this->notafiscal->getJson(),
221 | $result
222 | );
223 | }
224 | }
225 |
--------------------------------------------------------------------------------
/tests/ToolsFormatterTest.php:
--------------------------------------------------------------------------------
1 | assertEquals('textShouldBeCamelCased', $formatter->snakeToCamel('text_should_be_camel_cased'));
13 | }
14 | }
15 |
--------------------------------------------------------------------------------