diff --git a/README.md b/README.md index 6567d60..1d5b719 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,12 @@ +# WooCommerce NFe (NFe.io) -# Woo NFe +WooCommerce NFe é uma extensão do WooCommerce para emitir notas fiscais utilizando a API do NFe.io. -Woo NFe é uma extensão do WooCommerce para emitir notas fiscais utilizando a API do NFe.io +## Requisitos + +* PHP >= 5.5 +* WP >= 4.9 +* WooCommerce >= 3.3.5 ## Instalação @@ -9,3 +14,39 @@ Woo NFe é uma extensão do WooCommerce para emitir notas fiscais utilizando a A 2. Pesquise por *WooCommerce NFe*. 3. Clique em *Instalar Agora*. 4. Ativar o plugin + +Ou você pode colocar este plugin no diretório wp-content/plugins e ativá-lo. + +## Changelog ## + +### 1.0 +* Initial release + +### 1.0.1 +* Fix issue #6 + +### 1.0.2 +* Added trigger to issue invoices on specific status +* Fixed when issue invoices federal tax number must be only numbers + +### 1.0.3 +* Added support to issue invoices without all address fields filled + +### 1.0.4 +* Fix support to issue invoices without all address fields filled +* Fix trigger to issue invoices on specific status + +### 1.2.5 +* Added option to require an address when issuing an invoice. +* Fixed a bug where zero orders could be issued. +* Added notice in the order list when a order is zeroed. +* Added php require header on the readme.txt +* Fixed a bug that gave fatal error when on before PHP 5.5 versions. +* Fix - load_textdomain first from WP_LANG_DIR before load_plugin_textdomain +* Tweak - Tweak load_plugin_textdomain to be relative - this falls back to WP_LANG_DIR automatically. Can prevent "open_basedir restriction in effect". + +### 1.2.6 +* Fixing client-php folder conflict. + +### 1.2.7 +* Fixing how we verify the type of customer to output its information on the NFe receipt. diff --git a/README.txt b/README.txt index cff25d8..35f786f 100644 --- a/README.txt +++ b/README.txt @@ -3,9 +3,9 @@ Contributors: nfe, espellcaste Tags: woocommerce, shop, receipt, nfe, nota fiscal, nota, receita, sefaz, nfse, emitir nfse, emitir nfe Requires at least: 4.7 Tested up to: 4.9.4 -Stable tag: 1.2.6 +Stable tag: 1.2.7 Requires PHP: 5.5 -WC tested up to: 3.3.5 +WC tested up to: 3.4.3 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -22,22 +22,18 @@ WooCommerce NFe is a WooCommerce extension for issuing invoices using the NFe.io Thanks in advance for your help on any translation efforts! -== Frequently Asked Questions == - == Installation == -1. Upload woo-nfe.zip to wp-content/plugins -2. Click "Activate" in the WordPress plugins menu +1. Go the *Plugins* menu and click *Add New*. +2. Search for *WooCommerce NFe*. +3. Click *Install Now*. -== Changelog == - -= 1.0.0 = -* Initial commit +or -= 1.0.1 = -* Fix issue #6 +1. Upload woo-nfe.zip to wp-content/plugins folder +2. Click "Activate" in the WordPress plugins menu -== Upgrade Notice == +== Changelog == = 1.0.0 = * Initial release @@ -67,3 +63,6 @@ Thanks in advance for your help on any translation efforts! = 1.2.6 = * Fixing client-php folder conflict. + += 1.2.7 = +* Fixing how we verify the type of customer to output its information on the NFe receipt. diff --git a/composer.json b/composer.json index c866f58..3d3de7c 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ }, { "name" : "Renato Alves", - "homepage": "http://ralv.es/" + "homepage": "https://ralv.es/" } ], "support": { diff --git a/includes/admin/class-api.php b/includes/admin/class-api.php index f6d46e8..0f3db56 100755 --- a/includes/admin/class-api.php +++ b/includes/admin/class-api.php @@ -65,7 +65,7 @@ public function issue_invoice( $order_ids = array() ) { $this->logger( $log ); $order->add_order_note( $log ); - // If value is 0, don't issue it. + // If value is 0.00, don't issue it. if ( '0.00' === $order->get_total() ) { $log = sprintf( __( 'Not possible to issue NFe without an order value! Order: #%d', 'woo-nfe' ), $order_id ); $this->logger( $log ); @@ -160,33 +160,33 @@ public function order_info( $order_id ) { $order = nfe_wc_get_order( $order_id ); $address = [ - 'postalCode' => $this->check_customer_info( 'cep', $order_id ), - 'street' => $this->remover_caracter( $this->check_customer_info( 'street', $order_id ) ), - 'number' => $this->remover_caracter( $this->check_customer_info( 'address_number', $order_id ) ), + 'postalCode' => $this->check_customer_info( 'cep', $order_id ), + 'street' => $this->remover_caracter( $this->check_customer_info( 'street', $order_id ) ), + 'number' => $this->remover_caracter( $this->check_customer_info( 'address_number', $order_id ) ), 'additionalInformation' => $this->remover_caracter( get_post_meta( $order_id, '_billing_address_2', true ) ), - 'district' => $this->remover_caracter( $this->check_customer_info( 'district', $order_id ) ), - 'country' => $this->remover_caracter( $this->billing_country( $order_id ) ), - 'state' => $this->remover_caracter( $this->check_customer_info( 'state', $order_id ) ), - 'city' => [ - 'code' => $this->ibge_code( $order_id ), - 'name' => $this->remover_caracter( $this->check_customer_info( 'city', $order_id ) ), + 'district' => $this->remover_caracter( $this->check_customer_info( 'district', $order_id ) ), + 'country' => $this->remover_caracter( $this->billing_country( $order_id ) ), + 'state' => $this->remover_caracter( $this->check_customer_info( 'state', $order_id ) ), + 'city' => [ + 'code' => $this->ibge_code( $order_id ), + 'name' => $this->remover_caracter( $this->check_customer_info( 'city', $order_id ) ), ], ]; - $borrower = array( - 'name' => $this->remover_caracter( $this->check_customer_info( 'name', $order_id ) ), - 'email' => get_post_meta( $order_id, '_billing_email', true ), - 'federalTaxNumber' => $this->removepontotraco( $this->check_customer_info( 'number', $order_id ) ), - 'address' => $address, - ); + $borrower = [ + 'name' => $this->check_customer_info( 'name', $order_id ), + 'email' => get_post_meta( $order_id, '_billing_email', true ), + 'federalTaxNumber' => $this->removepontotraco( $this->check_customer_info( 'number', $order_id ) ), + 'address' => $address, + ]; - $data = array( - 'cityServiceCode' => $this->city_service_info( 'code', $order_id ), - 'federalServiceCode' => $this->city_service_info( 'fed_code', $order_id ), - 'description' => $this->remover_caracter( $this->city_service_info( 'desc', $order_id ) ), - 'servicesAmount' => $order->get_total(), - 'borrower' => $borrower, - ); + $data = [ + 'cityServiceCode' => $this->city_service_info( 'code', $order_id ), + 'federalServiceCode' => $this->city_service_info( 'fed_code', $order_id ), + 'description' => $this->remover_caracter( $this->city_service_info( 'desc', $order_id ) ), + 'servicesAmount' => $order->get_total(), + 'borrower' => $borrower, + ]; // Removes empty, false and null fields from the array. return array_filter( $data ); @@ -222,7 +222,7 @@ protected function billing_country( $order_id ) { * Fetche the IBGE Code. * * @param int $order_id Order ID. - * @return string + * @return string|null */ protected function ibge_code( $order_id ) { $key = $this->get_key(); @@ -317,31 +317,37 @@ protected function check_customer_info( $field = '', $order ) { return; } - // Customer Person Type. - (int) $type = get_post_meta( $order, '_billing_persontype', true ); + // Person Type. + $type = get_post_meta( $order, '_billing_persontype', true ); switch ( $field ) { - case 'number': // Customer ID Number. - if ( 1 === $type || empty( $type ) ) { - $output = $this->cpf( get_post_meta( $order, '_billing_cpf', true ) ); - } elseif ( 2 === $type || empty( $type ) || empty( $output ) ) { - $output = $this->cnpj( get_post_meta( $order, '_billing_cnpj', true ) ); + case 'number': + if ( ! empty( $type ) ) { + if ( '1' === $type ) { + $output = $this->cpf( get_post_meta( $order, '_billing_cpf', true ) ); + } else { + $output = $this->cnpj( get_post_meta( $order, '_billing_cnpj', true ) ); + } } break; - case 'name': // Customer Name/Razão Social. - if ( 1 === $type || empty( $type ) ) { - $output = get_post_meta( $order, '_billing_first_name', true ) . ' ' . get_post_meta( $order, '_billing_last_name', true ); - } elseif ( 2 === $type || empty( $type ) || empty( $output ) ) { - $output = get_post_meta( $order, '_billing_company', true ); + case 'name': + if ( ! empty( $type ) ) { + if ( '1' === $type ) { + $output = get_post_meta( $order, '_billing_first_name', true ) . ' ' . get_post_meta( $order, '_billing_last_name', true ); + } else { + $output = get_post_meta( $order, '_billing_company', true ); + } } break; - case 'type': // Customer Type. - if ( 1 === $type || empty( $type ) ) { - $output = __( 'Customers', 'woo-nfe' ); - } elseif ( 2 === $type ) { - $output = __( 'Company', 'woo-nfe' ); + case 'type': + if ( ! empty( $type ) ) { + if ( '1' === $type ) { + $output = __( 'Customers', 'woo-nfe' ); + } else { + $output = __( 'Company', 'woo-nfe' ); + } } break; @@ -701,7 +707,7 @@ protected function country_iso_codes() { 'VNM' => 'VN', // Vietnam 'YEM' => 'YE', // Yemen 'ZAF' => 'ZA', // South Africa - 'ZWE' => 'ZW', // Zimbabwe + 'ZWE' => 'ZW', // Zimbabwe. ); } diff --git a/includes/admin/class-emails.php b/includes/admin/class-emails.php index db96839..7da1cfb 100644 --- a/includes/admin/class-emails.php +++ b/includes/admin/class-emails.php @@ -1,38 +1,36 @@ customer_email = true; // Triggers. - add_action( 'woocommerce_order_status_pending_to_processing_notification', array( $this, 'trigger' ) ); - add_action( 'woocommerce_order_status_pending_to_completed_notification', array( $this, 'trigger' ) ); - add_action( 'woocommerce_order_status_completed_notification', array( $this, 'trigger' ) ); - add_action( 'woocommerce_renewal_order_payment_complete', array( $this, 'trigger') ); + add_action( 'woocommerce_order_status_pending_to_processing_notification', array( $this, 'trigger' ) ); + add_action( 'woocommerce_order_status_pending_to_completed_notification', array( $this, 'trigger' ) ); + add_action( 'woocommerce_order_status_completed_notification', array( $this, 'trigger' ) ); + add_action( 'woocommerce_renewal_order_payment_complete', array( $this, 'trigger') ); parent::__construct(); } diff --git a/package.json b/package.json index a951e42..5d7df72 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nfe", "title": "WooCommerce NFe", - "version": "1.2.4", + "version": "1.2.7", "author": "NFe.io", "homepage": "https://github.com/nfe/woo-nfe", "description": "WooCommerce extension for issuing invoices using the NFe.io API", diff --git a/templates/emails/nfe-receipt-issued.php b/templates/emails/nfe-receipt-issued.php index 22eaf1d..5c34ee6 100644 --- a/templates/emails/nfe-receipt-issued.php +++ b/templates/emails/nfe-receipt-issued.php @@ -1,5 +1,4 @@ -
+ download_pdf_invoice( array( $order ) ); - - $this->assertNotNull($pdf); - } - /** * NFe Fields */ public function test_nfe_options_fields() { $nfe_fields = nfe_get_field(); - $this->assertNotNull($nfe_fields); + $this->assertNotNull( $nfe_fields ); } } diff --git a/woo-nfe.php b/woo-nfe.php index edd2775..fab0998 100644 --- a/woo-nfe.php +++ b/woo-nfe.php @@ -11,7 +11,7 @@ * Plugin Name: WooCommerce NFe * Plugin URI: https://github.com/nfe/woo-nfe * Description: WooCommerce extension for the NFe API - * Version: 1.2.6 + * Version: 1.2.7 * Author: NFe.io * Author URI: https://nfe.io * Developer: Project contributors @@ -20,8 +20,8 @@ * Domain Path: /languages * Network: false * - * WC requires at least: 3.3.3 - * WC tested up to: 3.3.3 + * WC requires at least: 3.3.5 + * WC tested up to: 3.4.3 * * Copyright: © 2018 NFe.io * License: GNU General Public License v3.0